Exemple #1
0
        public void Send(short msgType, JHSMessageBase packet)
        {
            try
            {
                lock (ToSend)
                    ToSend.Enqueue(new SendState()
                    {
                        msgType = msgType, packet = packet
                    });

                if (sendbegined)
                {
                    return;
                }
                sendbegined = true;
                BeginSend();
            }
            catch
            {
                if (NetConfig.UseStatistics)
                {
                    SendError += 1;
                }
            }
        }
Exemple #2
0
 public void Send(uint connectionId, short msgType, JHSMessageBase msg)
 {
     if (connection != null && connection.ConnectionReady())
     {
         connection.Send(msgType, msg);
         return;
     }
     if (NetConfig.logFilter >= JHSLogFilter.Error)
     {
         JHSDebug.LogError("JHSNetworkManager :: CLIENT BASE TRANSPORT Failed to send message to connection ID '" + connectionId + ", not found in connection list");
     }
 }
 internal void InternalSend(short msgType, JHSMessageBase msg)
 {
     if (m_activeTransport != null)
     {
         m_activeTransport.Send(0, msgType, msg);
         return;
     }
     if (NetConfig.logFilter >= JHSLogFilter.Error)
     {
         JHSDebug.LogError("JHSNetworkManager :: Failed to send message to connection ID '" + 0 + ", not found in connection list");
     }
 }
Exemple #4
0
 public void Send(uint connectionId, short msgType, JHSMessageBase msg)
 {
     if (m_Connections.TryGetValue(connectionId, out JHSConnection conection))
     {
         if (conection != null)
         {
             conection.Send(msgType, msg);
             return;
         }
     }
     if (NetConfig.logFilter >= JHSLogFilter.Error)
     {
         JHSDebug.LogError("JHSNetworkServer :: Failed to send message to connection ID '" + connectionId + ", not found in connection list");
     }
 }
 public byte[] ToBytes(short msgType, JHSMessageBase 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 >= JHSLogFilter.Developer)
         {
             JHSDebug.Log("JHSPacketFarmer Write:" + BitConverter.ToString(nesent));
         }
         return(nesent);
     }
 }
Exemple #6
0
 public void SendToAll(short msgType, JHSMessageBase msg)
 {
     try
     {
         JHSConnection[] 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 >= JHSLogFilter.Error)
         {
             JHSDebug.LogError("JHSNetworkServer :: Exception:" + e.ToString());
         }
     }
 }
 public static void Send(short msgType, JHSMessageBase msg, bool diff = false)
 {
     Instance.InternalSend(msgType, msg);
 }
Exemple #8
0
 public void SendToAll(short msgType, JHSMessageBase msg)
 {
 }
 public void Write(JHSMessageBase msg)
 {
     msg.Serialize(this);
 }
Exemple #10
0
 public static void Send(uint connectionId, short msgType, JHSMessageBase msg)
 {
     Instance.InternalSend(connectionId, msgType, msg);
 }
Exemple #11
0
 public static void SendToAll(short msgType, JHSMessageBase msg)
 {
     Instance.InternalSendToAll(msgType, msg);
 }