Inheritance: global::ProtoBuf.IExtensible
Exemplo n.º 1
0
        //internal void RequestPeerList(bool requestOwner = false)
        //{
        //    uint regID;
        //    if (requestOwner)
        //    {
        //        regID = _b.RPC.PeersGetFriendList(RequestPeers.SetOption.OWNID);
        //        _pendingPeerRequests.Add(regID, RequestPeers.SetOption.OWNID);
        //    }
        //    else
        //    {
        //        regID = _b.RPC.PeersGetFriendList(RequestPeers.SetOption.FRIENDS);
        //        _pendingPeerRequests.Add(regID, RequestPeers.SetOption.FRIENDS);
        //    }
        //}
        //internal void ProcessResponsePeerList(uint reqID, ResponsePeerList response)
        //{
        //    RequestPeers.SetOption opt;
        //    if (_pendingPeerRequests.TryGetValue(reqID, out opt))
        //    {
        //        _pendingPeerRequests.Remove(reqID);
        //        switch (opt)
        //        {
        //            case RequestPeers.SetOption.OWNID:
        //                SetOwnID(response);
        //                break;
        //            case RequestPeers.SetOption.FRIENDS:
        //                UpdatePeerList(response);
        //                break;
        //            default:
        //                // all other cases
        //                break;
        //        }
        //    }
        //    else
        //    {
        //        // peer list - but no clue what is in it
        //    };
        //}
        internal void UpdatePeerList(ResponsePeerList msg)
        {
            // get new peerlist
            List<Person> _newPeerList = msg.peers;
            _newPeerList.Sort(new PersonComparer());

            // check if anything had changed
            if (EqualPeerLists(_peerList, _newPeerList))
                return;

            //save selected peer/location
            int index1 = _b.GUI.lb_friends.SelectedIndex, index2 = _b.GUI.lb_locations.SelectedIndex;
            _b.GUI.lb_friends.Items.Clear();
            ClearPeerForm();
            _peerList.Clear();

            _peerList = msg.peers;
            // i hope i don't need this anymore
            //if (_owner.locations.Count > 0)
            //    _peerList.Add(_owner);
            _peerList.Sort(new PersonComparer());

            foreach (Person p in _peerList)
            {
                byte online = 0, total = 0;
                foreach (rsctrl.core.Location l in p.locations)
                {
                    total++;
                    switch (l.state)
                    {
                        case ((uint)rsctrl.core.Location.StateFlags.CONNECTED):
                        case ((uint)rsctrl.core.Location.StateFlags.ONLINE):
                        case ((uint)(rsctrl.core.Location.StateFlags.CONNECTED | rsctrl.core.Location.StateFlags.ONLINE)):
                            online++;
                            break;
                        default: // offline
                            break;
                    }
                }
                _b.GUI.lb_friends.Items.Add("(" + online + "/" + total + ") " + p.name);
            }

            _b.GUI.lb_friends.SelectedIndex = index1;
            _b.GUI.lb_locations.SelectedIndex = index2;
        }
Exemplo n.º 2
0
 //private void ProcessAddPeer(RSProtoBuffSSHMsg msg)
 //{
 //    Respon response = new ResponseAddPeer();
 //    Exception e;
 //    if (RSProtoBuf.Deserialize<ResponseAddPeer>(msg.ProtoBuffMsg, out response, out e))
 //        _b.GUI.tb_out.AppendText("AddPeer response: " + response.status.code + "\n");
 //    else
 //        System.Diagnostics.Debug.WriteLine("ProcessAddPeer: error deserializing " + e.Message);
 //}
 //private void ProcessModifyPeer(RSProtoBuffSSHMsg msg)
 //{
 //    ResponseModifyPeer response = new ResponseModifyPeer();
 //    Exception e;
 //    if (RSProtoBuf.Deserialize<ResponseModifyPeer>(msg.ProtoBuffMsg, out response, out e))
 //        _b.GUI.tb_out.AppendText("AddPeer response: " + response.status.code + "\n");
 //    else
 //        System.Diagnostics.Debug.WriteLine("ProcessModifyPeer: error deserializing " + e.Message);
 //}
 private void ProcessPeerList(RSProtoBuffSSHMsg msg)
 {
     ResponsePeerList response = new ResponsePeerList();
     Exception e;
     if (RSProtoBuf.Deserialize<ResponsePeerList>(msg.ProtoBuffMsg, out response, out e))
         if (response.status.code == Status.StatusCode.SUCCESS)
             //_b.PeerProcessor.ProcessResponsePeerList(msg.ReqID, response);
             _b.PeerProcessor.UpdatePeerList(response);
         else
             System.Diagnostics.Debug.WriteLine("ProcessPeerList: error deserializing " + e.Message);
 }