Ejemplo n.º 1
0
        public bool Connect(string ipString, int port)
        {
            if (m_ClientSocket != null)
            {
                return(false);
            }

            m_ClientSocket               = new TcpClientSocket();
            m_ClientSocket.OnConnect    += OnConnected;
            m_ClientSocket.OnReceive    += OnReceived;
            m_ClientSocket.OnDisconnect += OnDisconnected;

            Status = ClientNetworkStatus.Connecting;

            m_ClientSocket.Connect(IPAddress.Parse(ipString), port);

            UpdateRunner.AddUpdate(this);

            return(true);
        }
Ejemplo n.º 2
0
        public void Listen(int port)
        {
            if (m_Port != port && m_serverSocket != null)
            {
                DebugLog.Warning("");
                Disconnect();
            }

            m_Port = port;

            m_serverSocket = new TcpServerSocket();

            m_serverSocket.OnClientConnect    += OnClientConnected;
            m_serverSocket.OnClientDisconnect += OnClientDisconnected;

            m_serverSocket.OnReceive    += OnReceived;
            m_serverSocket.OnDisconnect += OnDisconnected;

            m_serverSocket.Listen(m_Port);

            UpdateRunner.AddUpdate(this);
        }
Ejemplo n.º 3
0
        public void TriggerEvent(SystemObject sender, int eventID, float delayTime, params SystemObject[] values)
        {
            if (delayTime <= 0)
            {
                if (eventHandlerDic.TryGetValue(eventID, out List <EventHandler> handlerList))
                {
                    if (handlerList != null && handlerList.Count > 0)
                    {
                        for (var i = handlerList.Count - 1; i >= 0; --i)
                        {
                            if (handlerList[i] == null)
                            {
                                handlerList.RemoveAt(i);
                            }
                            else
                            {
                                handlerList[i](sender, eventID, values);
                            }
                        }
                    }
                }
            }
            else
            {
                EventData e = eventDataPool.Get();
                e.Sender    = sender;
                e.EventID   = eventID;
                e.DelayTime = delayTime;
                e.Values    = values;
                delayEvents.Add(e);

                if (delayEvents.Count == 1)
                {
                    UpdateRunner.AddUpdate(this);
                }
            }
        }