|
@@ -37,14 +37,14 @@ class SteamClient extends NetworkClient {
|
|
|
|
|
|
public var user : steam.User;
|
|
public var user : steam.User;
|
|
|
|
|
|
|
|
+ var shost : SteamHost;
|
|
var bigPacket : haxe.io.Bytes;
|
|
var bigPacket : haxe.io.Bytes;
|
|
var bigPacketPosition = 0;
|
|
var bigPacketPosition = 0;
|
|
- var blockSentId = 0;
|
|
|
|
- var blockRecvId = 0;
|
|
|
|
var cache : haxe.io.Bytes;
|
|
var cache : haxe.io.Bytes;
|
|
|
|
|
|
public function new(host, u) {
|
|
public function new(host, u) {
|
|
super(host);
|
|
super(host);
|
|
|
|
+ shost = Std.instance(host, SteamHost);
|
|
this.user = u;
|
|
this.user = u;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -60,12 +60,12 @@ class SteamClient extends NetworkClient {
|
|
host.sendCustom(SteamHost.CBIG_PACKET_DATA, data.sub(split * MAX_PAYLOAD_SIZE, data.length - split * MAX_PAYLOAD_SIZE), this);
|
|
host.sendCustom(SteamHost.CBIG_PACKET_DATA, data.sub(split * MAX_PAYLOAD_SIZE, data.length - split * MAX_PAYLOAD_SIZE), this);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- if( cache == null || cache.length <= data.length )
|
|
|
|
- cache = haxe.io.Bytes.alloc(data.length * 2 + 1);
|
|
|
|
- cache.blit(1, data, 0, data.length);
|
|
|
|
- cache.set(0, (blockSentId++) & 0xFF);
|
|
|
|
|
|
+ if( cache == null || cache.length < data.length + 4 )
|
|
|
|
+ cache = haxe.io.Bytes.alloc(data.length * 2 + 4);
|
|
|
|
+ cache.blit(4, data, 0, data.length);
|
|
|
|
+ cache.setInt32(0, @:privateAccess shost.sessionID);
|
|
//Sys.println(user + " > [" + data.length+"] " + (data.length > 100 ? data.sub(0,60).toHex()+"..."+data.sub(data.length-8,8).toHex() : data.toHex()));
|
|
//Sys.println(user + " > [" + data.length+"] " + (data.length > 100 ? data.sub(0,60).toHex()+"..."+data.sub(data.length-8,8).toHex() : data.toHex()));
|
|
- steam.Networking.sendP2P(user, cache, Reliable, 0, data.length + 1);
|
|
|
|
|
|
+ steam.Networking.sendP2P(user, cache, Reliable, 0, data.length + 4);
|
|
}
|
|
}
|
|
|
|
|
|
override function stop() {
|
|
override function stop() {
|
|
@@ -89,9 +89,11 @@ class SteamHost extends NetworkHost {
|
|
var server : steam.User;
|
|
var server : steam.User;
|
|
var onConnected : Bool -> Void;
|
|
var onConnected : Bool -> Void;
|
|
var input : haxe.io.BytesInput;
|
|
var input : haxe.io.BytesInput;
|
|
|
|
+ var sessionID : Int;
|
|
|
|
|
|
- public function new() {
|
|
|
|
|
|
+ public function new( sessionID : Int ) {
|
|
super();
|
|
super();
|
|
|
|
+ this.sessionID = sessionID;
|
|
isAuth = false;
|
|
isAuth = false;
|
|
self = new SteamClient(this, steam.Api.getUser());
|
|
self = new SteamClient(this, steam.Api.getUser());
|
|
input = new haxe.io.BytesInput(haxe.io.Bytes.alloc(0));
|
|
input = new haxe.io.BytesInput(haxe.io.Bytes.alloc(0));
|
|
@@ -200,6 +202,8 @@ class SteamHost extends NetworkHost {
|
|
}
|
|
}
|
|
|
|
|
|
function onData( from : steam.User, data : haxe.io.Bytes ) {
|
|
function onData( from : steam.User, data : haxe.io.Bytes ) {
|
|
|
|
+ if( data.getInt32(0) != sessionID )
|
|
|
|
+ return;
|
|
if( recordedData != null ) {
|
|
if( recordedData != null ) {
|
|
recordedData.addFloat(haxe.Timer.stamp() - recordedStart);
|
|
recordedData.addFloat(haxe.Timer.stamp() - recordedStart);
|
|
recordedData.addInt32(data.length);
|
|
recordedData.addInt32(data.length);
|
|
@@ -208,18 +212,10 @@ class SteamHost extends NetworkHost {
|
|
//Sys.println(from + " < [" + data.length+"] " + (data.length > 100 ? data.sub(0,60).toHex()+"..."+data.sub(data.length-8,8).toHex() : data.toHex()));
|
|
//Sys.println(from + " < [" + data.length+"] " + (data.length > 100 ? data.sub(0,60).toHex()+"..."+data.sub(data.length-8,8).toHex() : data.toHex()));
|
|
var c = Std.instance(getClient(from), SteamClient);
|
|
var c = Std.instance(getClient(from), SteamClient);
|
|
if( c == null ) {
|
|
if( c == null ) {
|
|
- // prevent messages coming from previous connection to reach us
|
|
|
|
- if( !isCustomMessage(data, CHELLO_CLIENT, 1) )
|
|
|
|
- return;
|
|
|
|
c = new SteamClient(this, from);
|
|
c = new SteamClient(this, from);
|
|
pendingClients.push(c);
|
|
pendingClients.push(c);
|
|
}
|
|
}
|
|
- if( (c.blockRecvId & 0xFF) != data.get(0) ) {
|
|
|
|
- logError("Out of order block received " + data.get(0) + " while expecting " + (c.blockRecvId & 0xFF));
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- c.blockRecvId++;
|
|
|
|
- @:privateAccess c.processMessagesData(data, 1, data.length);
|
|
|
|
|
|
+ @:privateAccess c.processMessagesData(data, 4, data.length);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|