// Connection due to 'add_server' message void onConnect(string hostname_or_ip, ushort port) { FunapiRpcPeer peer = new FunapiRpcPeer(getNextUid(), option_.DisableNagle); peer.SetAddr(hostname_or_ip, port); peer.SetEventHandler(onPeerEvent); peer.SetMessageHandler(onPeerMessage); peer_list_.Add(peer); peer.Connect(); }
// Connection from the address pool void onConnect(int index) { if (index >= option_.Addrs.Count) { FunDebug.Log("[RPC] Invalid connect index. index:{0} list size:{1}", index, option_.Addrs.Count); return; } cur_index_ = index; FunapiRpcPeer peer = new FunapiRpcPeer(getNextUid(), option_.DisableNagle); KeyValuePair <string, ushort> addr = option_.Addrs[index]; peer.SetAddr(addr.Key, addr.Value); peer.SetEventHandler(onPeerEventBeforeConnect); peer.SetMessageHandler(onPeerMessage); peer_list_.Add(peer); peer.Connect(); }