This commit is contained in:
2014-07-05 18:16:54 +04:00
parent 6cd5eaee75
commit e207de6eb6
5 changed files with 45 additions and 46 deletions

View File

@@ -1,5 +1,7 @@
package ru.m.armageddon.client;
import ru.m.armageddon.proto.User;
import ru.m.armageddon.proto.LoginResponse;
import protohx.Message;
import haxe.crypto.Md5;
import flash.Lib;
@@ -21,6 +23,7 @@ class Client implements IConnectionHandler {
private var connection:IConnection;
private var user:User;
public function new() {
connection = new FlashConnection("localhost", 5000, this);
@@ -31,10 +34,11 @@ class Client implements IConnectionHandler {
}
public function onConnected():Void {
var request = new LoginRequest();
request.login = "shmyga";
request.password = Md5.encode("xkbp8jh9z2");
connection.send(request);
connection.send(
new LoginRequest()
.setLogin("shmyga")
.setPassword(Md5.encode("xkbp8jh9z2"))
);
}
public function onDisconnected():Void {
@@ -45,7 +49,12 @@ class Client implements IConnectionHandler {
}
public function onPacket(packet:Message):Void {
public function onLoginResponse(packet:LoginResponse):Void {
this.user = packet.user;
L.d(TAG, "Loginned: " + user.nickname);
}
public function onPacket(packet:Message):Void {
L.d(TAG, "Unknown packet: " + Type.getClassName(Type.getClass(packet)).split(".").pop());
}
}