예제 #1
0
 /// <summary>
 /// Invoked when a client is connected.
 /// </summary>
 private void OnClientConnect(ClientConnectEventArgs e)
 {
     this.Enqueue(() =>
     {
         this.Add(e.Client);
     });
 }
예제 #2
0
        protected virtual void OnClientConnect(ClientConnectEventArgs e)
        {
            EventHandler <ClientConnectEventArgs> handler = ClientConnect;

            if (handler != null)
            {
                handler(this, e);
            }
        }
예제 #3
0
        private void onConnectedClient(object sender, ClientConnectEventArgs e)
        {
            this.Sessions.Add(e.ID, e.Session);
            this.NewSessions.Add(e.ID, e.Session);
            VebSocketClient vc = e.Session.Context.WebSocket.ToVebSocketClient();

            vc.SubscribeToMainloop(this.HDEHost);
            this.Clients.Add(e.ID, vc);
            this.NewClients.Add(e.ID, vc);
        }
예제 #4
0
        private void OnClientConnectedEvent(object sender, ClientConnectEventArgs e)
        {
            Console.WriteLine("Client connected.");
            // Triggers when a new client connects to the server
            int    type       = e.Type;
            string macAddress = e.MACAddress;
            string ipAddress  = e.IPAddress;

            Console.WriteLine("Mac: " + macAddress);
            if (type == 1)
            {
                // New Connection
                if (sims.ContainsKey(macAddress))
                {
                    // Sim is cached within the database
                    // Update cachec information as needed and trigger sim as "online"
                    if (ipAddress != sims[macAddress].IpAddress)
                    {
                        sims[macAddress].IpAddress = ipAddress;
                        //db.UpdateExistingSim("", ipAddress, macAddress, "");
                        db.UpdateExistingSim(sims[macAddress]);
                    }
                    sims[macAddress].Online = true;
                    // Update panel to show as online
                    simWinMain.UpdateOnlineStatus(true, macAddress);
                    SendUpdatedSimInfo(sims[macAddress]);
                }
                else
                {
                    // New sim connecting to system for first time
                    Simulator s = new Simulator(0, macAddress, ipAddress, macAddress, true, "");
                    db.NewSimConnection(s);
                    sims.Add(macAddress, s);
                    //simWinMain.AddNewSim(sims, macAddress);
                    //simulatorsMenuBTN_Click(null, null);
                }
                SendNextBookingInfo(macAddress, true);
            }
            else if (type == 2)
            {
                // Client disconnecting
                if (sims.ContainsKey(macAddress))
                {
                    sims[macAddress].Online = false;
                    simWinMain.UpdateOnlineStatus(false, macAddress);
                }
            }
        }
예제 #5
0
        private async Task <bool> HttpServer_BeginRequest(HttpContext context, CancellationToken cancellationToken)
        {
            var request  = context.Request;
            var response = context.Response;

            Core.Log.LibVerbose("Request received from {0}:{1} to {2} {3}", request.RemoteAddress, request.RemotePort, request.Method, request.RawUrl);

            var clientId = Guid.NewGuid();
            var ccEvent  = ClientConnectEventArgs.Retrieve(clientId);

            OnClientConnect?.Invoke(this, ccEvent);
            ClientConnectEventArgs.Store(ccEvent);

            context.Response.ContentType = Serializer.MimeTypes[0];
            var responseBuffer = default(MultiArray <byte>);

            if (context.Request.Method == HttpMethod.GET && EnableGetDescriptors && OnGetDescriptorsRequest != null)
            {
                var eArgs = ServerDescriptorsEventArgs.Retrieve();
                OnGetDescriptorsRequest(this, eArgs);
                responseBuffer = Serializer.Serialize(eArgs.Descriptors);
                ServerDescriptorsEventArgs.Store(eArgs);
            }
            if (context.Request.Method == HttpMethod.POST && !(OnMethodCallAsync is null))
            {
                Counters.IncrementBytesReceived(context.Request.PostData.Length);
                var messageRq = Serializer.Deserialize <RPCRequestMessage>(context.Request.PostData);
                var eArgs     = MethodEventArgs.Retrieve(clientId, messageRq, cancellationToken);
                await OnMethodCallAsync.InvokeAsync(this, eArgs).ConfigureAwait(false);

                if (eArgs.Response != null)
                {
                    responseBuffer = Serializer.Serialize(eArgs.Response);
                    OnResponseSent?.Invoke(this, eArgs.Response);
                }
                MethodEventArgs.Store(eArgs);
            }
            await responseBuffer.CopyToAsync(response.OutputStream).ConfigureAwait(false);

            Counters.IncrementBytesSent(responseBuffer.Count);
            return(true);
        }
예제 #6
0
        void OnClientConnect(IAsyncResult result)
        {
            var tcpClient = clientListener.EndAcceptTcpClient(result);

            string ip = ((IPEndPoint)tcpClient.Client.RemoteEndPoint).Address.ToString();

            var clientConnectArgs = new ClientConnectEventArgs(ip);

            if (!Program.ScriptManager.CallEvent("OnClientConnect", clientConnectArgs).Canceled)
            {
                var newClient = new Client(tcpClient, this);
                Clients.Add(newClient.Id, newClient);
            }
            else
            {
                tcpClient.Close();
            }

            clientListener.BeginAcceptTcpClient(OnClientConnect, null);
        }
예제 #7
0
		/// <summary>
		/// 游戏服务器连接事件函数
        /// 这个连接,仅说明是guard起来并连接到WEB服务器了;之后还需通过协议判断是哪个具体server起来了
		/// </summary>
		public void GameServerConnected(object sender, ClientConnectEventArgs e)
		{
			string address = e.RemoteAddress;
			int index = address.LastIndexOf(":");
			string ipAddress = address.Substring(0, index);
			int port = int.Parse(address.Substring(index + 1));
			long connectionId = e.ConnectionId;
            UInt16 GuardServers = 0;

			//游戏服务器认证开关
			if (SystemConfig.Current.NeedGuardAuthorization)
			{
				GameServerAuthentication auth = new GameServerAuthentication(connectionId, ipAddress, port, SystemConfig.Current.GuardAuthorizationTimeout);
				lock (_authenticationList.SyncRoot)
				{
					_authenticationList.Add(auth);
				}
				auth.Begin();
			}
			else
			{
                GameServer svr = null;
                string[] para = new string[16];
                for(int i=0;i<16;i++)
                {
                    para[i] = "0";
                }

				lock (_gameServerList.SyncRoot)
				{
					foreach (GameServer server in _gameServerList)
					{
						lock (server)
						{
							if (server.IpAddress  == ipAddress)
							{
                                if (svr == null) svr = server;
                                GuardServers++;
								if (!server.IsConnected)
								{
									server.OnConnected(connectionId, new byte[] { 1 }, port);
									//return;
								}

                                switch (server.Type)
                                {
                                    case GameServer.ServerType.goddess:
                                        para[0] = server.Id.ToString();
                                        break;
                                    case GameServer.ServerType.bishop:
                                        para[1] = server.Id.ToString();
                                        break;
                                    case GameServer.ServerType.gamecenter:
                                        para[2] = server.Id.ToString();
                                        break;
                                    case GameServer.ServerType.logserver:
                                        para[3] = server.Id.ToString();
                                        break;
                                    case GameServer.ServerType.gameserver:
                                        if (server.Name.IndexOf("01") > 0) para[4] = server.Id.ToString();
                                        else if (server.Name.IndexOf("02") > 0) para[5] = server.Id.ToString();
                                        else if (server.Name.IndexOf("03") > 0) para[6] = server.Id.ToString();
                                        else if (server.Name.IndexOf("04") > 0) para[7] = server.Id.ToString();
                                        else if (server.Name.IndexOf("05") > 0) para[8] = server.Id.ToString();
                                        else if (server.Name.IndexOf("06") > 0) para[9] = server.Id.ToString();
                                        else if (server.Name.IndexOf("07") > 0) para[10] = server.Id.ToString();
                                        else if (server.Name.IndexOf("08") > 0) para[11] = server.Id.ToString();
                                        else if (server.Name.IndexOf("09") > 0) para[12] = server.Id.ToString();
                                        else if (server.Name.IndexOf("10") > 0) para[13] = server.Id.ToString();
                                        else if (server.Name.IndexOf("11") > 0) para[14] = server.Id.ToString();
                                        else if (server.Name.IndexOf("12") > 0) para[15] = server.Id.ToString();
                                        break;
                                }
							}
						}
					}
				}

                if (svr != null)   svr.DoPlugInAction(SecurityManager.SystemAutomationId, E2gServerid.PlugInGuid, E2gServerid.actionKey, para);

				//断开没有记录的连接
                if (GuardServers == 0) 
				    AdminServer.TheInstance.ConnectionManager.Disconnect(connectionId);                
			}
		}
예제 #8
0
 public void client_onClientConnected(object o, ClientConnectEventArgs e)
 {
     Client_Log("Client is connected to: " + e.RemoteIP + ":" + e.Port.ToString());
 }
예제 #9
0
 public virtual void OnClientConnect(ClientConnectEventArgs e)
 {
     ClientConnect?.Invoke(this, e);
 }
예제 #10
0
 public void client_onClientConnected(object o, ClientConnectEventArgs e)
 {
     Client_Log("Client is connected to: " + e.RemoteIP + ":" + e.Port.ToString());
 }
예제 #11
0
 private static void Server_OnConnect(object sender, ClientConnectEventArgs e)
 {
     dic.Add(e.Session.IP, e.Session);
 }
예제 #12
0
파일: Service.cs 프로젝트: rctl/QuickLink
 /* ==== HANDLERS ===== */
 private void Server_ClientConnect(object sender, ClientConnectEventArgs e)
 {
     CreateConnection(e.NetworkClientService);
 }