[server] add module

This commit is contained in:
2020-03-25 16:24:53 +03:00
parent 821ddbb2a7
commit 8e3b9e2830
99 changed files with 70 additions and 4 deletions

View File

@@ -27,7 +27,7 @@ const config = new Project.Config({
meta: { meta: {
title: 'Puzzle\'z', title: 'Puzzle\'z',
filename: 'puzzlez', filename: 'puzzlez',
icon: 'src/resources/icon.png', icon: 'src/app/resources/icon.png',
pack: 'ru.m.puzzlez', pack: 'ru.m.puzzlez',
author: 'shmyga <shmyga.z@gmail.com>', author: 'shmyga <shmyga.z@gmail.com>',
company: 'MegaLoMania', company: 'MegaLoMania',
@@ -52,14 +52,15 @@ const app = new Project(
config.branch({ config.branch({
name: 'app', name: 'app',
sources: [ sources: [
'src/haxe', 'src/common/haxe',
'src/app/haxe',
], ],
android: [{ android: [{
path: 'dependencies/android', path: 'dependencies/android',
extensions: ['ru.m.android.FileUtil'], extensions: ['ru.m.android.FileUtil'],
}], }],
assets: [ assets: [
'src/resources', 'src/app/resources',
], ],
main: 'ru.m.puzzlez.PuzzlezApp', main: 'ru.m.puzzlez.PuzzlezApp',
meta: { meta: {
@@ -69,6 +70,22 @@ const app = new Project(
}), }),
).bind(module, gulp); ).bind(module, gulp);
const server = new Project(
Project.BuildSystem.HAXE,
[
Project.Platform.NEKO,
Project.Platform.CPP,
],
config.branch({
name: 'server',
sources: [
'src/common/haxe',
'src/server/haxe',
],
main: 'ru.m.puzzlez.PuzzlezServer',
})
).bind(module, gulp);
module.exports.publish = publish(packageInfo.name, packageInfo.version, Config.PublishDir, Config.PublishUrl); module.exports.publish = publish(packageInfo.name, packageInfo.version, Config.PublishDir, Config.PublishUrl);
const defaultSeries = [ const defaultSeries = [

View File

@@ -8,7 +8,7 @@
"gulp-add": "0.0.2", "gulp-add": "0.0.2",
"gulp-clean": "^0.4.0", "gulp-clean": "^0.4.0",
"gulp-cli": "^2.2.0", "gulp-cli": "^2.2.0",
"gulp-haxetool": "0.1.6", "gulp-haxetool": "0.1.7",
"yargs": "^13.2.4" "yargs": "^13.2.4"
}, },
"haxeDependencies": { "haxeDependencies": {

View File

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 25 KiB

View File

Before

Width:  |  Height:  |  Size: 503 B

After

Width:  |  Height:  |  Size: 503 B

View File

Before

Width:  |  Height:  |  Size: 499 B

After

Width:  |  Height:  |  Size: 499 B

View File

Before

Width:  |  Height:  |  Size: 569 B

After

Width:  |  Height:  |  Size: 569 B

View File

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

Before

Width:  |  Height:  |  Size: 741 B

After

Width:  |  Height:  |  Size: 741 B

View File

Before

Width:  |  Height:  |  Size: 740 B

After

Width:  |  Height:  |  Size: 740 B

View File

Before

Width:  |  Height:  |  Size: 540 B

After

Width:  |  Height:  |  Size: 540 B

View File

Before

Width:  |  Height:  |  Size: 564 B

After

Width:  |  Height:  |  Size: 564 B

View File

Before

Width:  |  Height:  |  Size: 582 B

After

Width:  |  Height:  |  Size: 582 B

View File

Before

Width:  |  Height:  |  Size: 619 B

After

Width:  |  Height:  |  Size: 619 B

View File

Before

Width:  |  Height:  |  Size: 681 B

After

Width:  |  Height:  |  Size: 681 B

View File

Before

Width:  |  Height:  |  Size: 580 B

After

Width:  |  Height:  |  Size: 580 B

View File

Before

Width:  |  Height:  |  Size: 160 KiB

After

Width:  |  Height:  |  Size: 160 KiB

View File

Before

Width:  |  Height:  |  Size: 78 KiB

After

Width:  |  Height:  |  Size: 78 KiB

View File

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 21 KiB

View File

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

Before

Width:  |  Height:  |  Size: 40 KiB

After

Width:  |  Height:  |  Size: 40 KiB

View File

@@ -0,0 +1,49 @@
package ru.m.puzzlez;
import hw.log.TraceLogger;
import cpp.net.ThreadServer;
import sys.net.Socket;
import haxe.io.Bytes;
typedef Session = Dynamic;
typedef Message = Bytes;
typedef ClientMessage<M> = {
var msg:M;
var bytes:Int;
}
class PuzzlezServer extends ThreadServer<Session, Message> {
private static inline var TAG = 'Server';
override public function clientConnected(socket:Socket):Session {
var session = null; // new Session(socket);
L.d(TAG, 'Client connected');
return session;
}
override public function clientDisconnected(session:Session) {
L.d(TAG, 'Client disconnected');
//session.disconnect();
}
override public function readClientMessage(session:Session, buf:Bytes, pos:Int, len:Int): ClientMessage<Message> {
//L.d(TAG, 'Client message: ${buf}');
return {msg: buf.sub(pos, len), bytes: len};
}
override public function clientMessage(session:Session, message:Message) {
//session.pushData(bytes);
}
public static function main():Void {
L.push(new TraceLogger());
L.d(TAG, 'Running');
L.i(TAG, 'Build: ${CompilationOption.get("build")}');
var host:String = Sys.args().length > 0 ? Sys.args()[0] : "0.0.0.0";
var port:Int = Sys.args().length > 1 ? Std.parseInt(Sys.args()[1]) : 5000;
var wserver = new PuzzlezServer();
L.i(TAG, 'Start on ${host}:${port}');
wserver.run(host, port);
}
}