Brunet.Connections.Connection.SetStatus C# (CSharp) Метод

SetStatus() публичный Метод

public SetStatus ( StatusMessage sm ) : ConnectionState>.Pair
sm StatusMessage
Результат ConnectionState>.Pair
    public Pair<ConnectionState,ConnectionState> SetStatus(StatusMessage sm) {
      var res = _state.Update(delegate(ConnectionState old_state) {
        if( old_state.Disconnected ) {
          throw new Exception(String.Format("Connection: {0} is disconnected",this));
        }
        var new_state = new ConnectionState(old_state.Edge, sm, old_state.PeerLinkMessage, false);
        return new_state;
      });
      ProtocolLog.WriteIf(ProtocolLog.Connections, String.Format(
            "SetStatus called on {0}, old status: {1}, new status: {2}", this, res.First.StatusMessage, sm));
      var ev = StateChangeEvent;
      if( null != ev ) {
        ev(this, res);
      }
      return res;
    }

Usage Example

Пример #1
0
 /**
  * Call the GetStatus method on the given connection
  */
 public void CallGetStatus(string type, Connection c) {
   if( c != null ) {
     StatusMessage req = GetStatus(type, c.Address);
     Channel stat_res = new Channel(1);
     EventHandler handle_result = delegate(object q, EventArgs eargs) {
       try {
         RpcResult r = (RpcResult)stat_res.Dequeue();
         c.SetStatus(new StatusMessage( (IDictionary)r.Result ));
       }
       catch(Exception) {
         //Looks like lc disappeared before we could update it
       }
     };
     stat_res.CloseEvent += handle_result;
     _rpc.Invoke(c.State.Edge, stat_res, "sys:link.GetStatus", req.ToDictionary() );
   }
 }
All Usage Examples Of Brunet.Connections.Connection::SetStatus