コード例 #1
0
ファイル: Client.cs プロジェクト: MatthiasLenz/TechniteLogic
 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();
 }
コード例 #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);
        }
コード例 #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);
        }
コード例 #4
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;
        }
コード例 #5
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;
        }
コード例 #6
0
ファイル: Client.cs プロジェクト: MatthiasLenz/TechniteLogic
		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();
		}