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

            compressionThreshold = -1;

            // force init
            PacketType.init();
        }
예제 #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);
        }
예제 #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);
 }
예제 #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));
        }
예제 #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);
        }
예제 #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);
        }
예제 #8
0
 public StreamPeerTCPStream(StreamPeerTCP tcp)
 {
     this.tcp = tcp;
 }
예제 #9
0
    // Called when the node enters the scene tree for the first time.

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