Beispiel #1
0
 public override void _Process(float delta)
 {
     if (connected && !client.IsConnectedToHost())
     {
         connected    = false;
         disconnected = true;
     }
     if (connected)
     {
         getPackets();
     }
     if (disconnected)
     {
         GD.Print(String.Format("Reconnecting to {0}:{1}", ip, port));
         client.ConnectToHost(ip, port);
         if (client.IsConnectedToHost())
         {
             client.SetNoDelay(true);
             client.SetBlockSignals(true);
             wrapped_client = new PacketPeerStream();
             wrapped_client.SetStreamPeer(client);
             connected    = true;
             disconnected = false;
             GD.Print("Reconnected.");
         }
         else
         {
             GD.Print("Failed to connect.");
         }
     }
 }
Beispiel #2
0
        public Client(string ip, int port)
        {
            StreamPeerTCP t = new StreamPeerTCP();

            GodotError.Assert(t.ConnectToHost(ip, port)); // Always gives zero
            tcp    = new StreamPeerTCPStream(t);
            reader = new BinaryReader(tcp);
            writer = new BinaryWriter(tcp);
        }
Beispiel #3
0
 public void Join(string ip = "127.0.0.1", int port = 27015)
 {
     // counter = 1;
     // connections.Clear();
     tcpstream = new StreamPeerTCP();
     // tcppeer = new PacketPeerStream();
     // tcppeer.StreamPeer = tcpstream;
     tcpstream.ConnectToHost(ip, port);
 }
Beispiel #4
0
        public static string AuthOnServer(string ip, int port)
        {
            socket = new StreamPeerTCP();
            var status = socket.ConnectToHost(ip, port);

            if (status != Error.Ok)
            {
                return(status.ToString());
            }

            Send(NET_CMD.INSTALL, SimpleJSON.JSON.Parse("{}"));
            return(null);
        }
Beispiel #5
0
        public static string ConnectToGame(string ip, int port)
        {
            Disconnect();

            var status = socket.ConnectToHost(ip, port);

            if (status != Error.Ok)
            {
                return(status.ToString());
            }

            GameIP   = ip;
            GamePort = port;
            seq      = 1;
            msgQueue.Clear();
            return(null);
        }
Beispiel #6
0
 public Error connect(String host, int port)
 {
     SetProcess(true);
     return(client.ConnectToHost(host, port));
 }