Beispiel #1
0
        /// <summary>
        /// Sends an object to the Server
        /// </summary>
        /// <typeparam name="T">Type of object to be sent</typeparam>
        /// <param name="objectToSend">The object to send to the server</param>
        public void Send <T>(T objectToSend)
        {
            byte[]       data            = BsonMagic.SerializeObject <T>(objectToSend);
            NetMQMessage messageToServer = new NetMQMessage();

            messageToServer.AppendEmptyFrame();
            messageToServer.Append(typeof(T).AssemblyQualifiedName);
            messageToServer.Append(data);

            clientSocket.SendMultipartMessage(messageToServer);
        }
Beispiel #2
0
        /// <summary>
        /// Send an object to a specified client
        /// </summary>
        /// <typeparam name="T">The type of the object being sent</typeparam>
        /// <param name="objectToSend">The object to send to the client</param>
        /// <param name="clientId">ID of the client to whom the object will be sent</param>
        public void Send <T>(T objectToSend, Guid clientId)
        {
            byte[] data = BsonMagic.SerializeObject <T>(objectToSend);

            NetMQMessage msgToSend = new NetMQMessage();

            msgToSend.Append(clientId.ToByteArray());
            msgToSend.AppendEmptyFrame();
            msgToSend.Append(typeof(T).AssemblyQualifiedName);
            msgToSend.Append(data);

            netMqSocket.SendMultipartMessage(msgToSend);
        }