public void SendDataBlock(DataBlock dataBlock) { using (NetPacket packet = new NetPacket()) { // -- Create string from datablock bytes string datablockString = Encoding.ASCII.GetString(dataBlock.GetBytes()); Logger.Log(LogLevel.L2_Info, "Sending datablock to server: " + datablockString, "NetworkMessages.FromClient"); packet.Write(datablockString); this.Send(packet); } }
void Awake() { // -- Initialize Logger Logger.SetPrinter(new Printer()); // -- Initialize the Configuration class Configuration.Initialize(); // -- Set Logger filter from Configuration Logger.SetFilter(Configuration.LoggerFilter); // -- Spawn an instance of Network Manager (This will run the constructor) NetworkManager.GetInstance(); }
protected override void HandleMessage(NetPacketBase packet) { try { // -- Create datablock from string DataBlock dataBlock = new DataBlock(Encoding.ASCII.GetBytes(packet.Read <string>())); // -- Pass datablock to datablock controller _networkManager.ProcessDataBlock(dataBlock); } catch (Exception e) { Logger.Log(LogLevel.L4_RecoverableError, "Error handling messge in NetworkSocket: " + e.StackTrace, "NetworkMessages.FromServer"); } }
public static void Initialize() { Logger.Log(LogLevel.L2_Info, "Configuration initialized."); }
protected override void OnDisconnected() { Logger.Log(LogLevel.L2_Info, "Disconnected.", "Network.Disconnect"); }
protected override void OnConnected() { Logger.Log(LogLevel.L2_Info, "Connected to " + this.Socket.RemoteEndPoint.ToString(), "Network.Connect"); }