[server] add session

This commit is contained in:
2020-03-25 21:05:15 +03:00
parent 8e3b9e2830
commit 8da310a6e5
16 changed files with 609 additions and 12 deletions

View File

@@ -1,5 +1,9 @@
package ru.m.puzzlez;
import hw.connect.ConnectionFactory;
import ru.m.puzzlez.proto.pack.Request;
import ru.m.puzzlez.proto.pack.Response;
import hw.connect.IConnection;
import hw.log.TraceLogger;
import hw.app.App;
import hw.app.Const;
@@ -12,6 +16,7 @@ import ru.m.update.Updater;
class PuzzlezApp {
@:provide static var updater:Updater;
@:provide static var connection:IConnection<Response, Request>;
public static function main() {
// ToDo: fix @:provide macro
@@ -19,6 +24,8 @@ class PuzzlezApp {
ImageStorage;
SettingsStorage;
L.push(new TraceLogger());
connection = ConnectionFactory.buildClientConnection("127.0.0.1", 6000, Request);
connection.connect().then(_ -> L.i("connect", "success")).catchError(error -> L.e("connect", "", error));
updater = new Updater(Const.instance.VERSION, "https://shmyga.ru/repo/puzzlez/packages.json");
var app = new App();
app.theme = new PuzzlezTheme();

View File

@@ -186,7 +186,7 @@ class Render extends SpriteView implements IRender {
}
activePart = pointPart;
tableView.setChildIndex(activePart, tableView.numChildren - 1);
activePoint = tableView.globalToLocal(point);
activePoint = RenderUtil.convertPoint(tableView.globalToLocal(point));
tableView.stage.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
tableView.stage.addEventListener(MouseEvent.MOUSE_UP, onMouseUp);
signal.emit(ACTION(PART_TAKE(activePart.id)));
@@ -194,14 +194,14 @@ class Render extends SpriteView implements IRender {
}
private function onMouseMove(event:MouseEvent):Void {
var newPoint:Point = tableView.globalToLocal(new FlashPoint(event.stageX, event.stageY));
var newPoint:Point = RenderUtil.convertPoint(tableView.globalToLocal(new FlashPoint(event.stageX, event.stageY)));
var partPosition = activePart.position.add(newPoint).subtract(activePoint);
signal.emit(ACTION(PART_MOVE(activePart.id, partPosition.clone())));
activePoint = newPoint;
}
private function onMouseUp(event:MouseEvent):Void {
var newPoint:Point = tableView.globalToLocal(new FlashPoint(event.stageX, event.stageY));
var newPoint:Point = RenderUtil.convertPoint(tableView.globalToLocal(new FlashPoint(event.stageX, event.stageY)));
var partPosition = activePart.position.add(newPoint).subtract(activePoint);
signal.emit(ACTION(PART_PUT(activePart.id, partPosition.clone())));
tableView.stage.removeEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);

View File

@@ -116,4 +116,8 @@ class RenderUtil {
var height = source.height * s;
return new Rectangle((target.width - width) / 2, (target.height - height) / 2, width, height);
}
public static function convertPoint(point:flash.geom.Point):Point {
return new Point(point.x, point.y);
}
}