SendPacket() public method

public SendPacket ( G2Packet packet ) : int
packet G2Packet
return int
Beispiel #1
0
        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);
        }
Beispiel #2
0
        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"));
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
        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;
        }
Beispiel #5
0
        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);
            }
        }
Beispiel #6
0
 void Receive_Ping(XConnection connection, GenericPacket ping)
 {
     Log("Pong Sent");
     connection.SendPacket(new GenericPacket("Pong"));
 }
Beispiel #7
0
        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;
        }
Beispiel #8
0
 void Receive_Ping(XConnection connection, GenericPacket ping)
 {
     Log("Pong Sent");
     connection.SendPacket(new GenericPacket("Pong"));
 }
Beispiel #9
0
        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);
            }
        }
Beispiel #10
0
        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);
        }
Beispiel #11
0
        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"));
        }