Beispiel #1
0
        private static void SendData(NetBuffer data)
        {
            var client = NetClient.Instance();

            client.Send(data);
        }
Beispiel #2
0
        private static void HandleStatusChange(NetIncomingMessage msg)
        {
            var status = (NetConnectionStatus)msg.ReadByte();
            var reason = msg.ReadString();

            Console.WriteLine(NetUtility.ToHexString(msg.SenderConnection.RemoteUniqueIdentifier) + " " + status + ": " + reason);
            // Do stuff here when we are connected/disconnected.
            if (status == NetConnectionStatus.Connected)
            {
                // If we're connecting to anything but the auth server, we'll need to send them a hello to authenticate ourselves with.
                var authhost = String.Format("{0}:{1}", Properties.Settings.Default["Hostname"] as String, (Int32)Properties.Settings.Default["Port"]);
                var curhost  = String.Format("{0}:{1}", NetClient.Instance().Hostname, NetClient.Instance().Port);
                if (!authhost.Equals(curhost))
                {
                    Send.AuthenticateClient(Data.MyGUID);
                }
            }
        }