internal void SendClientSettings() { if (XRay.IsInvokeRequired()) { XRay.RunInCoreAsync(() => SendClientSettings()); return; } if (ServerConnection == null) { return; } var packet = new GenericPacket("Settings"); packet.Data = new Dictionary <string, string>() { { "TargetFps", XRay.TargetFps.ToString() }, { "TrackFunctionHits", XRay.TrackFunctionHits.ToString() }, { "FlowTracking", XRay.FlowTracking.ToString() }, { "InstanceTracking", XRay.InstanceTracking.ToString() }, { "TrackRemoteProfiling", XRay.Remote.TrackRemoteProfiling.ToString() }, { "TrackRemoteThreadlines", XRay.Remote.TrackRemoteThreadlines.ToString() } }; ServerConnection.SendPacket(packet); }
internal void OnConnected(XConnection connection) { if (XRay.IsInvokeRequired()) { XRay.RunInCoreAsync(() => OnConnected(connection)); return; } // runs when client connects to server, not the other way around (that's what OnAccept is for) RemoteStatus = "Requesting Dat Hash"; connection.SendPacket(new GenericPacket("DatHashRequest")); }
void Receive_DatHashRequest(XConnection connection, GenericPacket request) { var response = new GenericPacket("DatHashResponse"); response.Data = new Dictionary <string, string> { { "Hash", XRay.DatHash }, { "Size", XRay.DatSize.ToString() } }; Log("Sending Dat Hash"); connection.SendPacket(response); }
void Send_StartSync(XConnection connection) { RemoteStatus = "Starting Sync"; // send packet telling server to start syncing us XRay.Init(LocalDatPath, true, true, true); XRay.StartGui(); connection.SendPacket(new GenericPacket("StartSync")); SendClientSettings(); // need to send after sync started ServerConnection = connection; }
void Receive_DatHashResponse(XConnection connection, GenericPacket response) { // only one instance type per builder instance because xray is static if (XRay.InitComplete && RemoteDatHash != null && RemoteDatHash != response.Data["Hash"]) { RemoteStatus = "Open a new builder instance to connect to a new server"; connection.Disconnect(); return; } // check if we have this hash.dat file locally, if not then request download RemoteDatHash = response.Data["Hash"]; RemoteDatSize = long.Parse(response.Data["Size"]); LocalDatPath = Path.Combine(RemoteCachePath, RemoteDatHash + ".dat"); LocalDatTempPath = Path.Combine(RemoteCachePath, RemoteDatHash + ".tmp"); if (RemoteDatSize == 0) { RemoteStatus = "Error - Remote Dat Empty"; } else if (File.Exists(LocalDatPath)) { Send_StartSync(connection); } else { Log("Requesting Dat File, size: " + RemoteDatSize.ToString()); RemoteStatus = "Requesting Dat File"; var request = new GenericPacket("DatFileRequest"); connection.SendPacket(request); } }
void Receive_Ping(XConnection connection, GenericPacket ping) { Log("Pong Sent"); connection.SendPacket(new GenericPacket("Pong")); }
void Receive_DatHashResponse(XConnection connection, GenericPacket response) { // only one instance type per builder instance because xray is static if (XRay.InitComplete && RemoteDatHash != null && RemoteDatHash != response.Data["Hash"]) { RemoteStatus = "Open a new builder instance to connect to a new server"; connection.Disconnect(); return; } // check if we have this hash.dat file locally, if not then request download RemoteDatHash = response.Data["Hash"]; RemoteDatSize = long.Parse(response.Data["Size"]); LocalDatPath = Path.Combine(RemoteCachePath, RemoteDatHash + ".dat"); LocalDatTempPath = Path.Combine(RemoteCachePath, RemoteDatHash + ".tmp"); if (RemoteDatSize == 0) RemoteStatus = "Error - Remote Dat Empty"; else if (File.Exists(LocalDatPath)) Send_StartSync(connection); else { Log("Requesting Dat File, size: " + RemoteDatSize.ToString()); RemoteStatus = "Requesting Dat File"; var request = new GenericPacket("DatFileRequest"); connection.SendPacket(request); } }
void Receive_DatHashRequest(XConnection connection, GenericPacket request) { var response = new GenericPacket("DatHashResponse"); response.Data = new Dictionary<string, string> { {"Hash", XRay.DatHash}, {"Size", XRay.DatSize.ToString()} }; Log("Sending Dat Hash"); connection.SendPacket(response); }