Exemplo n.º 1
0
        public void Receive(ReceiveMessageEventArgs eventargs)
        {
            Message message = eventargs.m_message;

            if (!m_server.m_replicationService.IsMaster)
            {
                // TODO: reply, in future: redirect question?
                DebugInfo ("Got request intended for master.");
                m_server.m_replicationService.SendImNotMasterMessage (message);
                return;
            }

            // All we need from the request is the source
            // uri.
            DebugInfo ("Server {0} got request for sequence number from {1}", m_server.UserName, message.GetSourceUserName ());

            // Create response to the requester
            Message response = new Message ();
            response.SetSourceUri (m_server.UserName);
            response.SetDestinationUsers (message.GetSourceUserName ());
            response.SetMessageType ("sequencenumber");

            long nextSequenceNumber = GetSequenceNumber ();
            response.PushString (nextSequenceNumber.ToString ());

            // this is implictly a blocking call
            m_server.m_replicationService.ReplicateSequenceNumber (nextSequenceNumber);

            m_server.m_sendReceiveMiddleLayer.Send (response);
        }
Exemplo n.º 2
0
 public object Clone()
 {
     Message m = new Message ();
     m.SetSourceUri (this.GetSourceUri ());
     m.SetSourceUserName (this.GetSourceUserName ());
     m.SetMessageType (this.GetMessageType ());
     m.SetDestinationUsers (this.GetDestinationUsers ());
     m.m_items = this.m_items;
     return m;
 }
Exemplo n.º 3
0
        public void Send(Message m, string uri)
        {
            // If channel is paused, then throw exception
            // so that deferred send continues after
            // the client re-connects

            m.SetSourceUri (GetURI ());

            // get reference to remote object
            PointToPointInterface p2p_send;
            if (m_dummy == null)
            {
                DebugLogic ("Sending to {0}", uri);
                p2p_send = (PointToPointInterface) Activator.GetObject (typeof (PointToPointInterface), uri);
            }
            else
            {
                p2p_send = m_dummy;
            }

            // ohoy!
            if (p2p_send == null)
            {
                DebugLogic ("Crash! Cannot find recipient: {0}", uri);
            }
            else
            {
                AsyncCallback cb = new AsyncCallback(MyCallBack);
                RemoteAsyncDelegate d = new RemoteAsyncDelegate (p2p_send.Deliver);
                d.BeginInvoke(m, cb, null);

                e.WaitOne ();
            }
        }