Beispiel #1
0
 /// <summary>
 /// Sends a pingOK packet to the client and handles the received ping
 /// </summary>
 /// <param name="packet"></param>
 private void handleReceivedPing(ServerIncomingPacket packet)
 {
     if (sendPing && !receivedPing)
     {
         this.pingResponseTime.Stop();
         lastResponseTime = this.pingResponseTime.ElapsedMilliseconds;
         Out.writeNotification(string.Format("Connection {0} ping response: ping = {1}ms", handeler.ID, pingResponseTime.ElapsedMilliseconds));
         this.receivedPing = true;
     }
     handeler.sendPacket(new PingOkPacket());
 }
Beispiel #2
0
 private void ConnectionHandeler_packetArrival(ServerIncomingPacket packet)
 {
     PacketRegistery<ServerOpCode, ServerIncomingPacket>.handlePacket handeler = packetRegister.getHandeler(packet.Opcode);
     if (handeler != null)
         handeler.Invoke(packet);
 }
Beispiel #3
0
 private void ServerReceivedVersion(ServerIncomingPacket packet)
 {
     //Handle version packet
 }
Beispiel #4
0
        private void buildRemainingPacket()
        {
            if (buffer.Length < this.currentLengthOfPacket) // Wait for more data...
                throw new BufferUnderflowException("Not enought data in the buffer, we need to wait for more!");

            byte[] packetData = new byte[this.currentLengthOfPacket];
            Array.Copy(buffer, packetData, packetData.Length);

            if (buffer.Length == this.currentLengthOfPacket)
                buffer = null;
            else
            {
                byte[] byteBuffer = new byte[buffer.Length - this.currentLengthOfPacket];
                Array.Copy(this.buffer, this.currentLengthOfPacket, byteBuffer, 0, byteBuffer.Length);
                buffer = byteBuffer;
            }

            currentLengthOfPacket = -1;
            // Create new packet
            ServerIncomingPacket incomingPacket = new ServerIncomingPacket(packetData);

            // use C# events to tell every-one that there was a new packet
            if (packetArrival != null)
                packetArrival.Invoke(incomingPacket);
        }
 private void OnUserCountUpdate(ServerIncomingPacket packet)
 {
     this.details.UserCount = packet.ReadInt();
     this.details.triggerDetailsChanged(UpdateType.User_count_update);
 }
 private void OnServerFull(ServerIncomingPacket packet)
 {
     this.details.ServerFull = true;
     this.details.triggerDetailsChanged(UpdateType.Server_is_full);
 }
 private void OnQueryResult(ServerIncomingPacket packet)
 {
     this.details.QueryResult = packet.ReadBoolean();
     this.details.triggerDetailsChanged(UpdateType.Query_result_status);
 }
 private void OnLicenseReceived(ServerIncomingPacket packet)
 {
     this.connectionHandeler.removeHandeler(ServerOpCode.License_Response);
     string username = packet.ReadString();
     string license = packet.ReadString();
     try
     {
         this.myLicense = AwsomeLicense.licenseRequester.GetLicense(username,license);
         this.gettingData = true;
         this.getDataThread = new Thread(LoopDaLoop);
         TriggerUpdate();
     }
     catch (InvalidLicenseException)
     {
         connectionHandeler.sendPacket(new ServerDenied("License incorrect!"));
         connectionHandeler.Dispose();
     }
 }