コード例 #1
0
ファイル: ServerSocket.cs プロジェクト: rexperalta/OCTGN
 public ServerSocket(TcpClient client, Server server) : base(new DeadLog())
 {
     client.Client.SendTimeout = 4000;
     this.Setup(client,new ServerMessageProcessor());
     Server = server;
     LastPingTime = DateTime.Now;
 }
コード例 #2
0
ファイル: Service.cs プロジェクト: jonbonne/OCTGN
 public void Start()
 {
     Log.Info("Starting");
     this.OnStart(null);
     Server = new Server(GameStateEngine.GetContext(), Program.BroadcastPort);
     Server.OnStop += (sender, args) => { if (!StopCalled) this.Stop(); };
     Log.Info("Started");
 }
コード例 #3
0
ファイル: Service.cs プロジェクト: pakoito/OCTGN
 public void Start()
 {
     Log.Info("Starting");
     this.OnStart(null);
     if(!Program.Local)
         SasManagerServiceClient.GetContext().Start();
     Server = new Server(GameStateEngine.GetContext());
     Server.OnStop += (sender, args) => { if (!StopCalled) this.Stop(); };
     Log.Info("Started");
 }
コード例 #4
0
ファイル: Handler.cs プロジェクト: YoshiEnVerde/OCTGN
 // Handle a binary message
 internal void ReceiveMessage(byte[] data, TcpClient sender,Server.Connection con)
 {
     // Check if this is the first message received
     if(!clients.ContainsKey(sender))
     {
         // A new connection must always start with a <Hello> xml message, refuse the connection
         sender.GetStream().Close(); return;
     }
     // Set the sender field
     this.sender = sender;
     this.Connection = con;
     // Parse and handle the message
     binParser.Parse(data);
 }
コード例 #5
0
ファイル: Handler.cs プロジェクト: YoshiEnVerde/OCTGN
 // Show the management GUI
 //        internal void ShowGUI(System.Windows.Forms.Form parent)
 //        {
 //            ManagementForm cf = new ManagementForm(clients);
 //            cf.ShowDialog(parent);
 //        }
 // Handle an XML message
 internal void ReceiveMessage(string msg, TcpClient sender, Server.Connection con)
 {
     // Check if this is the first message received
     if(!clients.ContainsKey(sender))
     {
         // A new connection must always start with a <Hello> message.
         if(!msg.StartsWith("<Hello>", StringComparison.Ordinal))
         {
             // Refuse the connection
             sender.GetStream().Close(); return;
         }
     }
     // Set the sender field
     this.sender = sender;
     this.Connection = con;
     // Parse and handle the message
     xmlParser.Parse(msg);
 }
コード例 #6
0
ファイル: Server.cs プロジェクト: Kamalisk/OCTGN
            private int _packetPos; // Current position in the packet buffer

            #endregion Fields

            #region Constructors

            // C'tor
            internal Connection(Server server, TcpClient client)
            {
                // Init fields
                _server = server;
                Client = client;
                //Start ping thread
                _pingThread = new Thread(DoPing);
                _lastPing = DateTime.Now;
                _pingThread.Start();
                // Start reading
                client.GetStream().BeginRead(_buffer, 0, 512, Receive, null);
            }
コード例 #7
0
ファイル: Handler.cs プロジェクト: saturnattack/OCTGN
 // Show the management GUI
 //        internal void ShowGUI(System.Windows.Forms.Form parent)
 //        {
 //            ManagementForm cf = new ManagementForm(clients);
 //            cf.ShowDialog(parent);
 //        }
 // Handle a Binary message
 internal void ReceiveMessage(byte[] data, TcpClient lSender, Server.Connection con)
 {
     // Check if this is the first message received
     if (!_clients.ContainsKey(lSender))
     {
         // A new connection must always start with a hello message, refuse the connection
         if (data[4] != (byte)2)
         {
             lSender.GetStream().Close();
             return;
         }
     }
     // Set the lSender field
     _sender = lSender;
     _connection = con;
     // Parse and handle the message
     _binParser.Parse(data);
 }
コード例 #8
0
ファイル: Program.cs プロジェクト: kellyelton/octgnwlobby
 public static void StopGame()
 {
     Client.Disconnect(); Client = null;
     if (Server != null)
     { Server.Stop(); Server = null; }
     Game.End(); Game = null;
     Dispatcher = null;
     Database.Close();
     IsGameRunning = false;
 }