示例#1
0
        public static void SendRequestCommand(ProtocolConstants.RequestCommands command, StreamCommunication streamCommunication)
        {
            var requestData = ConversionHandler.ConvertCommandToByte(ProtocolConstants.Commands.REQUEST);
            var commandData = ConversionHandler.ConvertRequestCommandToByte(command);

            streamCommunication.Write(requestData);
            streamCommunication.Write(commandData);
        }
示例#2
0
        public static void SendCommentData(StreamCommunication streamCommunication, Comment comment)
        {
            var nameData    = ConversionHandler.ConvertStringToBytes(comment.Commentator.Name, User.UserNameLength);
            var emailData   = ConversionHandler.ConvertStringToBytes(comment.Commentator.Email, User.UserEmailLength);
            var commentData = ConversionHandler.ConvertStringToBytes(comment.Message, Comment.CommentLength);

            streamCommunication.Write(nameData);
            streamCommunication.Write(emailData);
            streamCommunication.Write(commentData);
        }
示例#3
0
        public static void SendUserData(StreamCommunication streamCommunication, User user)
        {
            var nameData           = ConversionHandler.ConvertStringToBytes(user.Name, User.UserNameLength);
            var emailData          = ConversionHandler.ConvertStringToBytes(user.Email, User.UserEmailLength);
            var lastConnectionData = ConversionHandler.ConvertLongToBytes(user.LastConnection.ToBinary());

            streamCommunication.Write(nameData);
            streamCommunication.Write(emailData);
            streamCommunication.Write(lastConnectionData);
        }
示例#4
0
        public static async Task <MessageResponse> RecieveMessageCommand(StreamCommunication streamCommunication)
        {
            var response        = ConversionHandler.ConvertBytesToShort(await streamCommunication.ReadAsync(ProtocolConstants.ShortTypeLength));
            var responseCommand = ConversionHandler.ConvertBytesToShort(await streamCommunication.ReadAsync(ProtocolConstants.ShortTypeLength));
            var responseMessage = ConversionHandler.ConvertBytesToString(await streamCommunication.ReadAsync(ProtocolConstants.ResponseMessageLength));

            return(new MessageResponse()
            {
                Message = responseMessage,
                responseCommands = (ProtocolConstants.ResponseCommands)responseCommand
            });
        }
示例#5
0
        public static void SendPhotoData(StreamCommunication streamCommunication, Photo photo)
        {
            var email    = ConversionHandler.ConvertStringToBytes(photo.User.Email, User.UserEmailLength);
            var photoId  = ConversionHandler.ConvertLongToBytes(photo.Id);
            var nameData = ConversionHandler.ConvertStringToBytes(photo.Name, Photo.PhotoNameLength);
            var extData  = ConversionHandler.ConvertStringToBytes(photo.Extension, Photo.PhotoExtensionLength);
            var sizeData = ConversionHandler.ConvertLongToBytes(photo.FileSize);

            streamCommunication.Write(email);
            streamCommunication.Write(photoId);
            streamCommunication.Write(nameData);
            streamCommunication.Write(extData);
            streamCommunication.Write(sizeData);
        }
示例#6
0
 public static void SendMessageCommand(ProtocolConstants.ResponseCommands response, CommunicationClient client, string message)
 {
     SendResponseCommand(response, client.StreamCommunication);
     client.StreamCommunication.Write(ConversionHandler.ConvertStringToBytes(message, ProtocolConstants.ResponseMessageLength));
 }