public void NewConnection(StreamPeerTCP conn, long counter)
 {
     foreach (var obj in objects)
     {
         conn.PutVar(SendObject(obj.Value));
     }
 }
Esempio n. 2
0
        public override void _Ready()
        {
            client = new StreamPeerTCP();

            compressionThreshold = -1;

            // force init
            PacketType.init();
        }
Esempio n. 3
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);
        }
Esempio n. 4
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);
 }
Esempio n. 5
0
        public ServerMessage(StreamPeerTCP socket)
        {
            var _size = Utilites.Byte2IntBE((byte[])socket.GetData(4)[1]);

            cmd = (NET_CMD)Utilites.Byte2UShortBE((byte[])socket.GetData(2)[1]);
            seq = Utilites.Byte2UShortBE((byte[])socket.GetData(2)[1]);
            var _data = (byte[])socket.GetData(_size)[1];

            data = SimpleJSON.JSON.Parse(System.Text.Encoding.UTF8.GetString(_data, 0, _size));
        }
Esempio n. 6
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);
        }
Esempio n. 7
0
        public int ReadNextVarIntFromStream(StreamPeerTCP stream)
        {
            int i = 0;
            int j = 0;
            int k;

            while (true)
            {
                k  = stream.GetU8();
                i |= (k & 0x7F) << j++ *7;
                if (j > 5)
                {
                    throw new OverflowException("VarInt too big ");
                }
                if ((k & 0x80) != 128)
                {
                    break;
                }
            }

            return(i);
        }
 public StreamPeerTCPStream(StreamPeerTCP tcp)
 {
     this.tcp = tcp;
 }
Esempio n. 9
0
    // Called when the node enters the scene tree for the first time.

    public override void _Ready()
    {
        client = new StreamPeerTCP();
        client.SetBigEndian(true);
    }