[server] add module
23
gulpfile.js
@@ -27,7 +27,7 @@ const config = new Project.Config({
|
||||
meta: {
|
||||
title: 'Puzzle\'z',
|
||||
filename: 'puzzlez',
|
||||
icon: 'src/resources/icon.png',
|
||||
icon: 'src/app/resources/icon.png',
|
||||
pack: 'ru.m.puzzlez',
|
||||
author: 'shmyga <shmyga.z@gmail.com>',
|
||||
company: 'MegaLoMania',
|
||||
@@ -52,14 +52,15 @@ const app = new Project(
|
||||
config.branch({
|
||||
name: 'app',
|
||||
sources: [
|
||||
'src/haxe',
|
||||
'src/common/haxe',
|
||||
'src/app/haxe',
|
||||
],
|
||||
android: [{
|
||||
path: 'dependencies/android',
|
||||
extensions: ['ru.m.android.FileUtil'],
|
||||
}],
|
||||
assets: [
|
||||
'src/resources',
|
||||
'src/app/resources',
|
||||
],
|
||||
main: 'ru.m.puzzlez.PuzzlezApp',
|
||||
meta: {
|
||||
@@ -69,6 +70,22 @@ const app = new Project(
|
||||
}),
|
||||
).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);
|
||||
|
||||
const defaultSeries = [
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
"gulp-add": "0.0.2",
|
||||
"gulp-clean": "^0.4.0",
|
||||
"gulp-cli": "^2.2.0",
|
||||
"gulp-haxetool": "0.1.6",
|
||||
"gulp-haxetool": "0.1.7",
|
||||
"yargs": "^13.2.4"
|
||||
},
|
||||
"haxeDependencies": {
|
||||
|
||||
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
|
Before Width: | Height: | Size: 503 B After Width: | Height: | Size: 503 B |
|
Before Width: | Height: | Size: 499 B After Width: | Height: | Size: 499 B |
|
Before Width: | Height: | Size: 569 B After Width: | Height: | Size: 569 B |
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 741 B After Width: | Height: | Size: 741 B |
|
Before Width: | Height: | Size: 740 B After Width: | Height: | Size: 740 B |
|
Before Width: | Height: | Size: 540 B After Width: | Height: | Size: 540 B |
|
Before Width: | Height: | Size: 564 B After Width: | Height: | Size: 564 B |
|
Before Width: | Height: | Size: 582 B After Width: | Height: | Size: 582 B |
|
Before Width: | Height: | Size: 619 B After Width: | Height: | Size: 619 B |
|
Before Width: | Height: | Size: 681 B After Width: | Height: | Size: 681 B |
|
Before Width: | Height: | Size: 580 B After Width: | Height: | Size: 580 B |
|
Before Width: | Height: | Size: 160 KiB After Width: | Height: | Size: 160 KiB |
|
Before Width: | Height: | Size: 78 KiB After Width: | Height: | Size: 78 KiB |
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
|
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 3.2 KiB |
|
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 40 KiB |
49
src/server/haxe/ru/m/puzzlez/PuzzlezServer.hx
Normal 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);
|
||||
}
|
||||
}
|
||||