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); } }
//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)); }
public void Write(string message) { try { LogsProcessed.Add(message); Writer.Write(DateTime.Now + " - " + "(" + Out.GetCaller() + ") " + message); LastLogTime = DateTime.Now; } catch (Exception) { } }
/// <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()); } }
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()); } }