Beispiel #1
0
        private bool joinAsSpectator()
        {
            try
            {
                Protocol.SerialInterface proc = Protocol.SerialInterface.Build(typeof(ClientFactionRequest));
                ClientFactionRequest     req  = new ClientFactionRequest();
                req.startFactionTypes = 2;
                Protocol.ByteBuffer buf = new Protocol.ByteBuffer(288);
                proc.SerializePacket((int)ChannelID.ClientFaction, req, buf);
                clientStream.Write(buf.GetArray(), 0, buf.Length);


                return(true);
            }
            catch (Exception e)
            {
                Log.error("Error while joining.", this);
                Log.error(e.Message, this);
            }
            disconnect();
            return(false);
        }
Beispiel #2
0
        private bool loginToSever()
        {
            try
            {
                tcpClient.Connect(ServerAddress, ServerPort);
                clientStream = tcpClient.GetStream();

                Protocol.SerialInterface proc = Protocol.SerialInterface.Build(typeof(String));
                String name             = "SpecRelay";
                Protocol.ByteBuffer buf = new Protocol.ByteBuffer(name.Length);
                proc.SerializePacket((int)Protocol.ChannelID.Hello, name, buf);
                clientStream.Write(buf.GetArray(), 0, buf.Length);
                return(true);
            }
            catch (Exception e)
            {
                Log.error("Error while logging in.", this);
                Log.error(e.Message, this);
            }
            disconnect();
            return(false);
        }