Exemplo n.º 1
0
        public void Send(byte[] bytes)
        {
            try
            {
                var gameSession = World.StorageManager.GetGameSession(UserId);
                if (gameSession != null)
                {
                    if (gameSession.InProcessOfReconection || gameSession.InProcessOfDisconnection)
                    {
                        return;
                    }
                    if (gameSession.Player.Controller != null)
                    {
                        gameSession.LastActiveTime = DateTime.Now;
                    }

                    XSocket.Write(bytes);
                    //Console.WriteLine(Out.GetCaller() + $" ({DateTime.Now})");
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine("->" + Out.GetCaller());
                //new ExceptionLog("socket", "Unable to send packet / Connected?", e);
            }
        }
Exemplo n.º 2
0
        //public static ConcurrentDictionary<int, MySqlConnection> Connections = new ConcurrentDictionary<int, MySqlConnection>();
        public static SqlDatabaseClient GetClient()
        {
            var Connection = new MySqlConnection(GenerateConnectionString());

            Connection.Open();
            //Connections.TryAdd(Connections.Count, Connection);
            Out.WriteDbLog("Client requested from " + Out.GetCaller());
            return(new SqlDatabaseClient(Connection));
        }
Exemplo n.º 3
0
 public void Write(string message)
 {
     try
     {
         LogsProcessed.Add(message);
         Writer.Write(DateTime.Now + " - " + "(" + Out.GetCaller() + ") " + message);
         LastLogTime = DateTime.Now;
     }
     catch (Exception)
     {
     }
 }
Exemplo n.º 4
0
 /// <summary>
 /// Send will execute a netty handle which will send bytes to socket
 /// </summary>
 /// <param name="bytes"></param>
 /// <returns></returns>
 public async Task Send(byte[] bytes)
 {
     try
     {
         var buffer = PooledByteBufferAllocator.Default.DirectBuffer();
         buffer.WriteBytes(bytes);
         await _context.WriteAndFlushAsync(buffer);
     }
     catch
     {
         Debug.WriteLine("->" + Out.GetCaller());
     }
 }
Exemplo n.º 5
0
 public async Task Send(byte[] bytes)
 {
     try
     {
         var buffer = PooledByteBufferAllocator.Default.DirectBuffer();
         buffer.WriteBytes(bytes);
         await Context.WriteAndFlushAsync(buffer);
     }
     catch
     {
         World.StorageManager.GetGameSession(UserId)?.KillSession();
         Debug.WriteLine("->" + Out.GetCaller());
     }
 }