Exemple #1
0
        public bool SendMessage(NetOutgoingMessage msg, NetDeliveryMethod method)
        {
            bool result = true;

            if (IsTcp)
            {
                try
                {
                    mTcpConnecton.SendBytes(msg.Data, msg.LengthBits, Hazel.SendOption.Reliable);
                }
                catch (Exception ex)
                {
                    Log.Error(ex.ToString());
                    result = false;
                }
                NetworkManagerServer.sInstance.GetServer().Recycle(msg);
            }
            else
            {
                try
                {
                    var ret = NetworkManagerServer.sInstance.GetServer().SendMessage(msg, mConnection, method);
                    //Log.Information($"packet send to {mConnection.RemoteEndPoint}, ret {ret}");
                }
                catch (Exception ex)
                {
                    Log.Error(ex.ToString());
                    result = false;
                }
            }
            return(result);
        }
Exemple #2
0
 public static void SendMessage(NetConnection con, TcpConnection tcp_con, bool isTcp, NetOutgoingMessage msg, NetDeliveryMethod method)
 {
     if (isTcp)
     {
         try
         {
             tcp_con.SendBytes(msg.Data, msg.LengthBits, Hazel.SendOption.Reliable);
         }
         catch (Exception ex)
         {
             Log.Error(ex.ToString());
         }
         NetworkManagerServer.sInstance.GetServer().Recycle(msg);
     }
     else
     {
         NetworkManagerServer.sInstance.GetServer().SendMessage(msg, con, method);
     }
 }