示例#1
0
        public void CommunicationsUnitTest()
        {
            using (SessionServer server = new SessionServer(new IPEndPoint(IPAddress.Any, IPEndPoint.MaxPort)))
            {
                server.CommuniqueReceived += new CommuniqueReceivedEventHandler(server_CommuniqueReceived);

                IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
                IPEndPoint clientEndPoint = new IPEndPoint(hostEntry.AddressList[0], IPEndPoint.MaxPort);
                using (SessionClient client = new SessionClient(clientEndPoint))
                {
                    Communique communique = new Communique("CommunicationsUnitTest");
                    client.SendCommunique(communique);
                }

            }
        }
 /// <summary>
 /// Intitializes a new instance of the CommuniqueReceivedEventArgs class.
 /// </summary>
 /// <param name="communique">The Communique that was recevied.</param>
 internal CommuniqueReceviedEventArgs(Communique communique)
 {
     this.communique = communique;
 }
示例#3
0
 /// <summary>
 /// Sends a Communique to a remote <see cref="SharpCore.Communications.SessionServer"/>.
 /// </summary>
 public void SendCommunique(Communique communique)
 {
     if (disposed) throw new ObjectDisposedException("SessionClient");
     formatter.Serialize(stream, new Communique(communique.Body, communique.HostName, DateTime.Now, DateTime.MinValue));
 }
 /// <summary>
 /// Sends an update for the specified CachedItem to all configured servers.
 /// </summary>
 /// <param name="client">The SessionClient used to send the update.</param>
 /// <param name="item">The CachedItem to be sent to all configured servers.</param>
 private void SendCommunique(SessionClient client, CachedItem item)
 {
     Communique communique = new Communique(item);
     client.SendCommunique(communique);
 }