private void ReceiveCallback(IAsyncResult ar) { if (clientState != ClientTCPState.Sleep) { try { int received = socket.EndReceive(ar); if (received <= 0) { Close(); } else { if (clientState != ClientTCPState.Sleep) { socket.BeginReceive(_buffer, 0, _buffer.Length, SocketFlags.None, new AsyncCallback(ReceiveCallback), null); } byte[] dataBuffer = new byte[received]; Array.Copy(_buffer, dataBuffer, received); HandleDataTCP.HandleNetworkInformation(this, dataBuffer); } } catch (Exception ex) { Global.serverForm.Debug(ex.Message + " " + ex.Source); Close(); } } }
public static void ServerStart() { try { HandleDataTCP.InitializeNetworkPackages(); Global.InitGlobals(); Global.serverForm.StatusIndicator(1); try { Global.data.GetAccount("1"); Global.data.GetMap(1); Global.serverForm.StatusIndicator(4); } catch (Exception ex) { Global.serverForm.StatusIndicator(4, ex); } } catch (Exception ex) { Global.serverForm.StatusIndicator(1, ex); } ServerTCP.SetupServer(); }