public AttachTransport ( |
||
transport | ||
return | void |
public void Connect (string address) { FunapiTcpTransport tcp_transport = new FunapiTcpTransport(address, 8022, FunEncoding.kProtobuf); FunapiHttpTransport http_transport = new FunapiHttpTransport(address, 8018, false, FunEncoding.kJson); network_ = new FunapiNetwork(true); network_.AttachTransport(tcp_transport); network_.AttachTransport(http_transport); network_.RegisterHandlerWithProtocol("pbuf_echo", TransportProtocol.kTcp, this.OnTcpEcho); network_.RegisterHandlerWithProtocol("echo", TransportProtocol.kHttp, this.OnHttpEcho); network_.Start(); }
private void Connect(TransportProtocol protocol) { DebugUtils.Log("-------- Connect --------\n{0}", DateTime.Now); if (network_ == null || !network_.SessionReliability) { network_ = new FunapiNetwork(with_session_reliability_); network_.ResponseTimeout = 10f; network_.OnSessionInitiated += new FunapiNetwork.SessionInitHandler(OnSessionInitiated); network_.OnSessionClosed += new FunapiNetwork.SessionCloseHandler(OnSessionClosed); network_.MaintenanceCallback += new FunapiNetwork.MessageEventHandler(OnMaintenanceMessage); network_.StoppedAllTransportCallback += new FunapiNetwork.NotifyHandler(OnStoppedAllTransport); network_.TransportConnectFailedCallback += new TransportEventHandler(OnTransportConnectFailed); network_.TransportDisconnectedCallback += new TransportEventHandler(OnTransportDisconnected); network_.RegisterHandler("echo", this.OnEcho); network_.RegisterHandler("pbuf_echo", this.OnEchoWithProtobuf); //network_.SetMessageProtocol(TransportProtocol.kTcp, "echo"); //network_.SetMessageProtocol(TransportProtocol.kUdp, "pbuf_echo"); FunapiTransport transport = GetNewTransport(protocol); network_.AttachTransport(transport); } else { if (!network_.HasTransport(protocol)) { FunapiTransport transport = GetNewTransport(protocol); network_.AttachTransport(transport); } network_.SetDefaultProtocol(protocol); } network_.Start(); }
public void Connect(string hostname_or_ip, ushort port, bool session_reliability) { bool need_to_start = false; Debug.Log(String.Format("Multicast server is at {0}:{1}", hostname_or_ip, port)); lock (lock_) { transport_ = new FunapiTcpTransport (hostname_or_ip, port, encoding_); DebugUtils.Assert (transport_ != null); network_ = new FunapiNetwork (session_reliability); network_.AttachTransport (transport_); network_.RegisterHandler(kMulticastMsgType, OnReceived); need_to_start = true; } if (need_to_start) { network_.Start (); } }
void Awake() { instance = gameObject.GetComponent<NetworkController>(); // facebook facebook = GameObject.Find("Play Controller").GetComponent<FacebookConnector>(); facebook.EventCallback += new SnEventHandler(OnFacebookEvent); facebook.Init(); // funapi network network = new FunapiNetwork(false); network.OnSessionInitiated += new FunapiNetwork.SessionInitHandler(OnSessionInitiated); network.OnSessionClosed += new FunapiNetwork.SessionCloseHandler(OnSessionClosed); FunapiTcpTransport transport = new FunapiTcpTransport(kServerIp, 8022, FunEncoding.kProtobuf); transport.AutoReconnect = true; network.AttachTransport(transport); network.RegisterHandler("sc_spawn_self", this.OnSpawnSelf); network.RegisterHandler("sc_spawn_other", this.OnSpawnOther); network.RegisterHandler("sc_update", this.OnUpdate); network.RegisterHandler("sc_killed", this.OnKilled); network.RegisterHandler("sc_face", this.OnFaceUpdate); }