54 lines
1.5 KiB
Haxe
Executable File
54 lines
1.5 KiB
Haxe
Executable File
package ru.m.armageddon.client;
|
|
|
|
import haxe.io.Bytes;
|
|
import flash.events.Event;
|
|
import flash.events.SecurityErrorEvent;
|
|
import flash.events.IOErrorEvent;
|
|
import haxe.io.BytesOutput;
|
|
import haxework.log.TraceLogger;
|
|
import flash.net.Socket;
|
|
|
|
|
|
|
|
class Client {
|
|
|
|
private static inline var TAG = "Armageddon";
|
|
|
|
public static function main() {
|
|
L.push(new TraceLogger());
|
|
L.d(TAG, Meta.getVersion());
|
|
new Client();
|
|
}
|
|
|
|
|
|
private var socket:Socket;
|
|
|
|
public function new() {
|
|
|
|
socket = new Socket();
|
|
socket.addEventListener(IOErrorEvent.IO_ERROR, function(error):Void {
|
|
L.e("SocketLogger", "", error);
|
|
});
|
|
socket.addEventListener(SecurityErrorEvent.SECURITY_ERROR, function(error):Void {
|
|
L.e("SocketLogger", "", error);
|
|
});
|
|
//socket.addEventListener(Event.CLOSE, closeHandler);
|
|
socket.addEventListener(Event.CONNECT, onConnect);
|
|
//socket.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
|
|
//socket.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
|
|
//socket.addEventListener(ProgressEvent.SOCKET_DATA, socketDataHandler);
|
|
socket.connect("localhost", 5000);
|
|
}
|
|
|
|
private function onConnect(_) {
|
|
var request = new LoginRequest();
|
|
request.login = "shmyga";
|
|
request.password = "xkbp8jh9z2";
|
|
var out = new BytesOutput();
|
|
request.writeTo(out);
|
|
var bytes = out.getBytes();
|
|
socket.writeShort(bytes.length);
|
|
socket.writeBytes(cast bytes.getData());
|
|
}
|
|
}
|