コード例 #1
0
        public void SendBytes(byte[] data, bool compress = false, bool encrypt = false, bool close = false)
        {
            var builder = new SimpleMessage(MessageType.Bytes, this, Debug)
                          .CompressMessage(compress)
                          .EncryptMessage(encrypt)
                          .SetBytes(data);

            builder.Build();
            SendToSocket(builder.PayLoad, close, false);
        }
コード例 #2
0
        public void SendMessage(string message, bool compress = false, bool encrypt = false, bool close = false)
        {
            var messageBuilder = new SimpleMessage(MessageType.Message, this, Debug)
                                 .CompressMessage(compress)
                                 .EncryptMessage(encrypt)
                                 .SetMessage(message);

            messageBuilder.Build();
            SendToSocket(messageBuilder.PayLoad, close, false);
        }
コード例 #3
0
        public void SendCustomHeader(string message, string header, bool compress = false, bool encrypt = false, bool close = false)
        {
            var builder = new SimpleMessage(MessageType.CustomHeader, this, Debug)
                          .CompressMessage(compress)
                          .EncryptMessage(encrypt)
                          .SetHeaderString(header)
                          .SetMessage(message);

            builder.Build();
            SendToSocket(builder.PayLoad, close, false);
        }
コード例 #4
0
        public void SendMessageContract(IMessageContract contract, bool compress = false, bool encrypt = false, bool close = false)
        {
            var builder = new SimpleMessage(MessageType.MessageContract, this, Debug)
                          .CompressMessage(compress)
                          .EncryptMessage(encrypt)
                          .SetHeaderString(contract.MessageHeader)
                          .SetBytes(contract.SerializeToBytes());

            builder.Build();
            SendToSocket(builder.PayLoad, close, false);
        }
コード例 #5
0
        public void SendBytes(int id, byte[] data, bool compress = false, bool encrypt = false, bool close = false)
        {
            var client         = GetClient(id);
            var messageBuilder = new SimpleMessage(MessageType.Bytes, this, Debug)
                                 .CompressMessage(compress)
                                 .EncryptMessage(encrypt)
                                 .SetBytes(data)
                                 .SetSendClient(client);

            messageBuilder.Build();
            SendToSocket(messageBuilder.PayLoad, close, false, id);
        }
コード例 #6
0
        public void SendMessage(int id, string message, bool compress = false, bool encrypt = false, bool close = false)
        {
            var client         = GetClient(id);
            var messageBuilder = new SimpleMessage(MessageType.Message, this, Debug)
                                 .CompressMessage(compress)
                                 .EncryptMessage(encrypt)
                                 .SetMessage(message)
                                 .SetSendClient(client);

            messageBuilder.Build();
            SendToSocket(messageBuilder.PayLoad, close, false, id);
        }
コード例 #7
0
        public void SendMessageWithMetadata(object message, IDictionary <object, object> metadata, bool compress = false, bool encrypt = false, bool close = false)
        {
            var builder = new SimpleMessage(MessageType.MessageWithMetadata, this, Debug)
                          .CompressMessage(compress)
                          .EncryptMessage(encrypt)
                          .SetMetadata(metadata)
                          .SetBytes(ObjectSerializer.SerializeObjectToBytes(message))
                          .SetHeaderString(message.GetType().AssemblyQualifiedName);

            builder.Build();
            SendToSocket(builder.PayLoad, close, false);
        }
コード例 #8
0
        public void SendObject(object obj, bool compress = false, bool encrypt = false, bool close = false)
        {
            if (ObjectSerializer == null)
            {
                throw new Exception("No ObjectSerializer is currently set.");
            }

            var builder = new SimpleMessage(MessageType.Object, this, Debug)
                          .CompressMessage(compress)
                          .EncryptMessage(encrypt)
                          .SetBytes(ObjectSerializer.SerializeObjectToBytes(obj))
                          .SetHeaderString(obj.GetType().AssemblyQualifiedName);

            builder.Build();

            SendToSocket(builder.PayLoad, close, false);
        }
コード例 #9
0
        protected void SendBasicAuthMessage()
        {
            var osVersion = Environment.OSVersion;

            var guid = string.IsNullOrEmpty(_clientGuid) ? Guid.NewGuid().ToString() : _clientGuid;

            var msg = guid + "|" + osVersion;

            var builder = new SimpleMessage(MessageType.BasicAuth, this, Debug)
                          .CompressMessage(false)
                          .EncryptMessage(true)
                          .SetMessage(msg);

            builder.Build();

            //Setting partial to true prevents MessageSubmitted invoke.
            SendToSocket(builder.PayLoad, false, true);
        }