public void Send(short msgType, BaseNetworkMessage packet)
        {
            try
            {
                lock (ToSend)
                    ToSend.Enqueue(new SendState()
                    {
                        msgType = msgType, packet = packet
                    });

                if (sendbegined)
                {
                    return;
                }
                sendbegined = true;
                BeginSend();
            }
            catch
            {
                if (NetConfig.UseStatistics)
                {
                    SendError += 1;
                }
            }
        }
Ejemplo n.º 2
0
 internal void InternalSend(short msgType, BaseNetworkMessage msg)
 {
     if (m_activeTransport != null)
     {
         m_activeTransport.Send(0, msgType, msg);
         return;
     }
     if (NetConfig.logFilter >= LogFilter.Error)
     {
         Log.Error("Failed to send message to connection ID '" + 0 + ", not found in connection list");
     }
 }
Ejemplo n.º 3
0
 public void Send(uint connectionId, short msgType, BaseNetworkMessage msg)
 {
     if (connection != null && connection.ConnectionReady())
     {
         connection.Send(msgType, msg);
         return;
     }
     if (NetConfig.logFilter >= LogFilter.Error)
     {
         Log.Error("CLIENT BASE TRANSPORT Failed to send message to connection ID '" + connectionId + ", not found in connection list");
     }
 }
Ejemplo n.º 4
0
 public void Send(uint connectionId, short msgType, BaseNetworkMessage msg)
 {
     if (m_Connections.TryGetValue(connectionId, out NetworkConnection conection))
     {
         if (conection != null)
         {
             conection.Send(msgType, msg);
             return;
         }
     }
     if (NetConfig.logFilter >= LogFilter.Error)
     {
         Log.Error("Failed to send message to connection ID '" + connectionId + ", not found in connection list");
     }
 }
Ejemplo n.º 5
0
 public byte[] ToBytes(short msgType, BaseNetworkMessage packet)
 {
     lock (m_Writer)
     {
         m_Writer.StartMessage(msgType);
         packet.Serialize(m_Writer);
         m_Writer.FinishMessage();
         byte[]      buf     = m_Writer.ToArray();
         List <byte> listbuf = new List <byte>();
         listbuf.AddRange(Write(PACKAGE_HEADER_ID));
         listbuf.AddRange(Write((ushort)buf.Length));
         listbuf.AddRange(buf);
         byte[] nesent = listbuf.ToArray();
         if (NetConfig.logFilter >= LogFilter.Developer)
         {
             Log.Debug("Write:" + BitConverter.ToString(nesent));
         }
         return(nesent);
     }
 }
Ejemplo n.º 6
0
 public void SendToAll(short msgType, BaseNetworkMessage msg)
 {
     try
     {
         NetworkConnection[] connections = m_Connections.Values.ToArray();
         for (int i = 0; i < connections.Length; i++)
         {
             if (connections[i] != null && connections[i].ConnectionReady())
             {
                 connections[i].Send(msgType, msg);
             }
         }
     }
     catch (Exception e)
     {
         if (NetConfig.logFilter >= LogFilter.Error)
         {
             Log.Error("Exception:" + e.ToString());
         }
     }
 }
Ejemplo n.º 7
0
 public static void Send(short msgType, BaseNetworkMessage msg, bool diff = false)
 {
     Instance.InternalSend(msgType, msg);
 }
Ejemplo n.º 8
0
 public static void Send(uint connectionId, short msgType, BaseNetworkMessage msg)
 {
     Instance.InternalSend(connectionId, msgType, msg);
 }
Ejemplo n.º 9
0
 public static void SendToAll(short msgType, BaseNetworkMessage msg)
 {
     Instance.InternalSendToAll(msgType, msg);
 }
Ejemplo n.º 10
0
 public void Write(BaseNetworkMessage msg)
 {
     msg.Serialize(this);
 }
Ejemplo n.º 11
0
 public void SendToAll(short msgType, BaseNetworkMessage msg)
 {
 }