void PeerOnMessageCallHandlers(IIncommingMessage message)
 {
     if (Handlers.ContainsKey(message.OpCode))
     {
         Handlers[message.OpCode].Handle(message);
     }
     else
     {
         Dj.Errorf("ClientsideLink rcv'd unhandled opcode {0}", message.OpCode);
     }
 }
 public bool UsingPeer(int peerid, out Session session)
 {
     if (peerSessions.TryGetValue(peerid, out session))
     {
         return(true);
     }
     else
     {
         Dj.Errorf("Peer {0} could not be used.", peerid);
         return(false);
     }
 }
Beispiel #3
0
 public PostAssistant(IIncommingMessage message)
 {
     this.message = message;
     try {
         this.action = Capn.Decrunchatize <ACTION>(message.AsBytes());
     } catch (System.InvalidCastException ex) {
         Dj.Errorf("Still gonna crash, but just a heads up: expecting " + typeof(ACTION).ToString() + ", not getting it.");
         throw ex;
     }
     this.reply = new REPLY();
     this.Done  = false;
 }
Beispiel #4
0
 public T Read <T>(int index)
 {
     if (index < 0 || index >= data.Length)
     {
         Dj.Errorf("KeyedData.Data got bad index {0}", index); return(default(T));
     }
     if (!(data[index] is T))
     {
         Dj.Errorf("KeyedData.Data cannot cast index {0} to bad type {1}", index, typeof(T).ToString()); return(default(T));
     }
     return((T)data[index]);
 }
Beispiel #5
0
        public void Post(int peerId, short opCode, object serializableObject)
        {
            IPeer peer = master.GetPeer(peerId);

            if (peer == null)
            {
                Dj.Errorf("Post to peer#{0} failed", peerId);
            }
            else
            {
                peer.SendMessage(opCode, Capn.Crunchatize(serializableObject));
            }
        }
Beispiel #6
0
 public void StoryApplyDelta(IDelta delta)
 {
     if (delta is D)
     {
         this.pagenumber = delta.pagenumber;
         if (this.ApplyDelta((D)delta))
         {
             // ok, handled
         }
         else
         {
             Dj.Errorf("Page {0}.ApplyDelta failed on delta {1}\n-- return false", this, delta);
         }
     }
     else
     {
         Dj.Crashf("BasePage expected delta of type {0}\n-- but got bad delta {1}", typeof(D), delta);
     }
 }