private void PacketReceiver_OnDataInvoke(ulong Id, BasePacket basePacket)
 {
     if (basePacket.packetType == PacketType.ConnectionStat)
     {
         ConnectionPacket cp = (ConnectionPacket)basePacket;
         if (cp.IsConnecting == true)
         {
             PrintStatusLabel("Connected");
             SceneManager.LoadScene("MainScene", LoadSceneMode.Single);
         }
         else
         {
             if (cp.HasError == true)
             {
                 socketClient.ErrorStop();
                 PrintStatusLabel("Already Connected");
             }
             else
             {
                 socketClient.Stop();
                 SceneManager.LoadScene("ConnectScene", LoadSceneMode.Single);
             }
         }
     }
     OnDataInvoke?.Invoke(basePacket);
 }
Beispiel #2
0
        public void AddSegment(byte[] segment, int offset)
        {
            segments.Write(segment, offset, segment.Length - offset);
            AddCount++;

            if (AddCount == SegmentCount)
            {
                BasePacket basePacket = (BasePacket)PacketDeserializer.Deserialize(segments);
                OnDataInvoke?.Invoke(basePacket, SegmentID);
                segments.Close();
                segments.Dispose();
                segments = null;
            }
        }
    private void Start()
    {
        receiverObj = gameObject.GetComponent <PacketReceiverObj>();
        receiverObj.Init();
        receiverObj.OnDataInvoke += (Id, basepacket) => { OnDataInvoke?.Invoke(Id, basepacket); };
        clientsManagerObj         = gameObject.GetComponent <ClientsManagerObj>();
        clientsManagerObj.Init(receiverObj);
        clientsManagerObj.clientsManager.OnPacketSended += (Id, basepacket) => { OnPacketSended?.Invoke(Id, basepacket); };
        ConnectedClients = clientsManagerObj.clientsManager.Clients;

        TaskQueue    = new Queue <Action>();
        socketServer = new SocketServer(TaskQueue, this, lockObject);
        UnmanagedConnectedClients = socketServer.clientsManager.SocketClients;
        UnmanagedPreClients       = socketServer.clientsManager.PreClients;
        socketServer.Start();
    }
Beispiel #4
0
 private void PacketReciver_OnDataInvoke(BasePacket basePacket, int segmentID)
 {
     OnDataInvoke?.Invoke(Id, basePacket);
     segmentCollecters.Remove(segmentID);
 }
Beispiel #5
0
 private void PacketReceiverObj_OnDataInvoke(ulong Id, BasePacket basePacket)
 {
     OnDataInvoke?.Invoke(Id, basePacket);
 }