public static VoiceMessageDTO getIncallPacket(byte[] recievedBuffer)
        {
            VoiceMessageDTO messageDTO = new VoiceMessageDTO();
            int totalRead = 0;
            int packetType = recievedBuffer[0];
            totalRead++;

            long userIdentity = getLong(recievedBuffer, totalRead, 8);
            totalRead += 8;

            long friendIdentity = getLong(recievedBuffer, totalRead, 8);
            totalRead += 8;

            int packetIDLength = recievedBuffer[totalRead];
            totalRead++;
            string packetID = Encoding.UTF8.GetString(recievedBuffer, totalRead, packetIDLength);// new String(recievedBuffer, totalRead, packetIDLength);
            totalRead += packetIDLength;

            //messageDTO.setPacketType(packetType);
            //messageDTO.setPacketID(packetID);
            //messageDTO.setUserIdentity(friendIdentity);
            //messageDTO.setFriendIdentity(userIdentity);
            messageDTO.PacketType = packetType;
            messageDTO.PacketID = packetID;
            messageDTO.UserIdentity = friendIdentity;
            messageDTO.FriendIdentity = userIdentity;

            return messageDTO;
        }
        public static VoiceMessageDTO getIncallPacket(byte[] recievedBuffer)
        {
            VoiceMessageDTO messageDTO = new VoiceMessageDTO();
            int             totalRead  = 0;
            int             packetType = recievedBuffer[0];

            totalRead++;

            long userIdentity = getLong(recievedBuffer, totalRead, 8);

            totalRead += 8;

            long friendIdentity = getLong(recievedBuffer, totalRead, 8);

            totalRead += 8;

            int packetIDLength = recievedBuffer[totalRead];

            totalRead++;
            string packetID = Encoding.UTF8.GetString(recievedBuffer, totalRead, packetIDLength);// new String(recievedBuffer, totalRead, packetIDLength);

            totalRead += packetIDLength;

            //messageDTO.setPacketType(packetType);
            //messageDTO.setPacketID(packetID);
            //messageDTO.setUserIdentity(friendIdentity);
            //messageDTO.setFriendIdentity(userIdentity);
            messageDTO.PacketType     = packetType;
            messageDTO.PacketID       = packetID;
            messageDTO.UserIdentity   = friendIdentity;
            messageDTO.FriendIdentity = userIdentity;

            return(messageDTO);
        }
        public static VoiceMessageDTO getSignalingPacketAnwser(byte[] recievedBuffer)
        {
            VoiceMessageDTO messageDTO = new VoiceMessageDTO();
            int             totalRead  = 0;
            int             packetType = recievedBuffer[0];

            totalRead++;
            long userIdentity = getLong(recievedBuffer, totalRead, 8);

            totalRead += 8;
            long friendIdentity = getLong(recievedBuffer, totalRead, 8);

            totalRead += 8;
            int packetIDLength = recievedBuffer[totalRead];

            totalRead++;
            string packetID = Encoding.UTF8.GetString(recievedBuffer, totalRead, packetIDLength);

            totalRead += packetIDLength;
            int callType = recievedBuffer[totalRead];

            totalRead++;

            messageDTO.PacketType     = packetType;
            messageDTO.PacketID       = packetID;
            messageDTO.UserIdentity   = friendIdentity;
            messageDTO.FriendIdentity = userIdentity;
            messageDTO.CallType       = callType;
            return(messageDTO);
        }
        public static VoiceMessageDTO getVoiceBusyMsg(byte[] recievedBuffer)
        {
            //Packet Type+User Idenity+Friend Idenity+PacketID Length+Packet ID+Message Length+Message

            VoiceMessageDTO messageDTO = new VoiceMessageDTO();
            int             totalRead  = 0;
            int             packetType = recievedBuffer[0];

            totalRead++;

            long userIdentity = getLong(recievedBuffer, totalRead, 8);

            totalRead += 8;

            long friendIdentity = getLong(recievedBuffer, totalRead, 8);

            totalRead += 8;

            int packetIDLength = recievedBuffer[totalRead];

            totalRead++;
            string packetID = Encoding.UTF8.GetString(recievedBuffer, totalRead, packetIDLength);

            //new String(recievedBuffer, totalRead, packetIDLength);
            totalRead += packetIDLength;

            int pushMsgLength = recievedBuffer[totalRead];

            totalRead++;
            string pushMessage = Encoding.UTF8.GetString(recievedBuffer, totalRead, pushMsgLength);//new String(recievedBuffer, totalRead, pushMsgLength);

            totalRead += pushMsgLength;

            //messageDTO.PacketType(packetType);
            //messageDTO.UserIdentity(userId);
            //messageDTO.PacketID(packetID);
            //messageDTO.FriendIdentity(friendIdentity);
            //messageDTO.setVoiceBusyMessage(pushMessage);

            messageDTO.PacketType       = packetType;
            messageDTO.PacketID         = packetID;
            messageDTO.UserIdentity     = friendIdentity;
            messageDTO.FriendIdentity   = userIdentity;
            messageDTO.VoiceBusyMessage = pushMessage;
            return(messageDTO);
        }
        public static VoiceMessageDTO getRegisterConfirmationPacket(
            byte[] receivedBuffer)
        { //Packet Type + Friend Idenity + PacketID Length+Packet ID + Voice Communication Port + Video Communication Port
            VoiceMessageDTO messageDTO = new VoiceMessageDTO();
            int             totalRead  = 0;
            int             packetType = receivedBuffer[0];

            totalRead++;

            long friendIdentity = getLong(receivedBuffer, totalRead, 8);

            totalRead += 8;

            int packetIDLength = receivedBuffer[totalRead];

            totalRead++;
            //   string packetID = new String(receivedBuffer, totalRead, packetIDLength); E
            string packetID = Encoding.UTF8.GetString(receivedBuffer, totalRead, packetIDLength);

            totalRead += packetIDLength;

            int bindingPort = getIntegerFromByte(totalRead, receivedBuffer);

            totalRead += 4;

            //byte[] address = new byte[4];
            //address[0] = receivedBuffer[totalRead++];
            //address[1] = receivedBuffer[totalRead++];
            //address[2] = receivedBuffer[totalRead++];
            //address[3] = receivedBuffer[totalRead++];

            int vedioComunicationPort = (int)getIntegerFromByte(totalRead, receivedBuffer);

            totalRead                        += 4;
            messageDTO.PacketType             = packetType;
            messageDTO.PacketID               = packetID;
            messageDTO.VoiceBindingPort       = bindingPort;
            messageDTO.FriendIdentity         = friendIdentity;
            messageDTO.VideoCommunicationPort = vedioComunicationPort;
            return(messageDTO);
        }
        public static VoiceMessageDTO getPushConfirmationPacket(byte[] recievedBuffer)
        {
            VoiceMessageDTO messageDTO = new VoiceMessageDTO();
            int             totalRead  = 0;
            int             packetType = recievedBuffer[0];

            totalRead++;

            long friendIdentity = getLong(recievedBuffer, totalRead, 8);

            totalRead += 8;

            int packetIDLength = recievedBuffer[totalRead];

            totalRead++;
            string packetID = Encoding.UTF8.GetString(recievedBuffer, totalRead, packetIDLength);

            totalRead                += packetIDLength;
            messageDTO.PacketType     = packetType;
            messageDTO.PacketID       = packetID;
            messageDTO.FriendIdentity = friendIdentity;
            return(messageDTO);
        }
        public static VoiceMessageDTO getVoiceBusyMsg(byte[] recievedBuffer)
        {
            //Packet Type+User Idenity+Friend Idenity+PacketID Length+Packet ID+Message Length+Message

            VoiceMessageDTO messageDTO = new VoiceMessageDTO();
            int totalRead = 0;
            int packetType = recievedBuffer[0];
            totalRead++;

            long userIdentity = getLong(recievedBuffer, totalRead, 8);
            totalRead += 8;

            long friendIdentity = getLong(recievedBuffer, totalRead, 8);
            totalRead += 8;

            int packetIDLength = recievedBuffer[totalRead];
            totalRead++;
            string packetID = Encoding.UTF8.GetString(recievedBuffer, totalRead, packetIDLength);
            //new String(recievedBuffer, totalRead, packetIDLength);
            totalRead += packetIDLength;

            int pushMsgLength = recievedBuffer[totalRead];
            totalRead++;
            string pushMessage = Encoding.UTF8.GetString(recievedBuffer, totalRead, pushMsgLength);//new String(recievedBuffer, totalRead, pushMsgLength);
            totalRead += pushMsgLength;

            //messageDTO.PacketType(packetType);
            //messageDTO.UserIdentity(userId);
            //messageDTO.PacketID(packetID);
            //messageDTO.FriendIdentity(friendIdentity);
            //messageDTO.setVoiceBusyMessage(pushMessage);

            messageDTO.PacketType = packetType;
            messageDTO.PacketID = packetID;
            messageDTO.UserIdentity = friendIdentity;
            messageDTO.FriendIdentity = userIdentity;
            messageDTO.VoiceBusyMessage = pushMessage;
            return messageDTO;
        }
        public static VoiceMessageDTO getSignalingPacketAnwser(byte[] recievedBuffer)
        {
            VoiceMessageDTO messageDTO = new VoiceMessageDTO();
            int totalRead = 0;
            int packetType = recievedBuffer[0];
            totalRead++;
            long userIdentity = getLong(recievedBuffer, totalRead, 8);
            totalRead += 8;
            long friendIdentity = getLong(recievedBuffer, totalRead, 8);
            totalRead += 8;
            int packetIDLength = recievedBuffer[totalRead];
            totalRead++;
            string packetID = Encoding.UTF8.GetString(recievedBuffer, totalRead, packetIDLength);
            totalRead += packetIDLength;
            int callType = recievedBuffer[totalRead];
            totalRead++;

            messageDTO.PacketType = packetType;
            messageDTO.PacketID = packetID;
            messageDTO.UserIdentity = friendIdentity;
            messageDTO.FriendIdentity = userIdentity;
            messageDTO.CallType = callType;
            return messageDTO;
        }
        public static VoiceMessageDTO getRegisterConfirmationPacket(
            byte[] receivedBuffer)
        {
            //Packet Type + Friend Idenity + PacketID Length+Packet ID + Voice Communication Port + Video Communication Port
            VoiceMessageDTO messageDTO = new VoiceMessageDTO();
            int totalRead = 0;
            int packetType = receivedBuffer[0];
            totalRead++;

            long friendIdentity = getLong(receivedBuffer, totalRead, 8);
            totalRead += 8;

            int packetIDLength = receivedBuffer[totalRead];
            totalRead++;
            //   string packetID = new String(receivedBuffer, totalRead, packetIDLength); E
            string packetID = Encoding.UTF8.GetString(receivedBuffer, totalRead, packetIDLength);
            totalRead += packetIDLength;

            int bindingPort = getIntegerFromByte(totalRead, receivedBuffer);
            totalRead += 4;

            //byte[] address = new byte[4];
            //address[0] = receivedBuffer[totalRead++];
            //address[1] = receivedBuffer[totalRead++];
            //address[2] = receivedBuffer[totalRead++];
            //address[3] = receivedBuffer[totalRead++];

            int vedioComunicationPort = (int)getIntegerFromByte(totalRead, receivedBuffer);
            totalRead += 4;
            messageDTO.PacketType = packetType;
            messageDTO.PacketID = packetID;
            messageDTO.VoiceBindingPort = bindingPort;
            messageDTO.FriendIdentity = friendIdentity;
            messageDTO.VideoCommunicationPort = vedioComunicationPort;
            return messageDTO;
        }
        public static VoiceMessageDTO getPushConfirmationPacket(byte[] recievedBuffer)
        {
            VoiceMessageDTO messageDTO = new VoiceMessageDTO();
            int totalRead = 0;
            int packetType = recievedBuffer[0];
            totalRead++;

            long friendIdentity = getLong(recievedBuffer, totalRead, 8);
            totalRead += 8;

            int packetIDLength = recievedBuffer[totalRead];
            totalRead++;
            string packetID = Encoding.UTF8.GetString(recievedBuffer, totalRead, packetIDLength);
            totalRead += packetIDLength;
            messageDTO.PacketType = packetType;
            messageDTO.PacketID = packetID;
            messageDTO.FriendIdentity = friendIdentity;
            return messageDTO;
        }