Exemple #1
0
 public void Transfer(ByteBuffer data)
 {
     if (ioStream == null)
     {
         return;
     }
     try
     {
         lock (ioStream)
         {
             ioStream.Write(data.GetArray(), 0, data.Length);
             ioStream.Flush();
             return;
         }
     }
     catch (IOException)
     { }
     catch (SocketException)
     { }
     catch (ObjectDisposedException)
     { }
     catch (Exception ex)
     {
         OnAbnormalException(ex);
     }
     Close();
 }
Exemple #2
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);
        }
Exemple #3
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);
        }
        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;
        }
        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;
        }
Exemple #6
0
		public void Transfer(ByteBuffer data)
		{
			if (ioStream == null)
				return;
			try
			{
				lock (ioStream)
				{
					ioStream.Write(data.GetArray(), 0, data.Length);
					ioStream.Flush();
					return;
				}
			}
			catch (IOException)
			{ }
			catch (SocketException)
			{ }
			catch (ObjectDisposedException)
			{ }
			catch (Exception ex)
			{
				OnAbnormalException(ex);
			}
			Close();
		}