Fun.FunapiNetwork.RegisterHandlerWithProtocol C# (CSharp) Method

RegisterHandlerWithProtocol() public method

public RegisterHandlerWithProtocol ( string type, TransportProtocol protocol, MessageEventHandler handler ) : void
type string
protocol TransportProtocol
handler MessageEventHandler
return void
        public void RegisterHandlerWithProtocol(string type, TransportProtocol protocol, MessageEventHandler handler)
        {
            if (protocol == TransportProtocol.kDefault)
            {
                RegisterHandler(type, handler);
                return;
            }

            DebugUtils.DebugLog("New handler for and message type '{0}' of '{1}' protocol.", type, protocol);
            message_protocols_[type] = protocol;
            message_handlers_[type] = handler;
        }

Usage Example

コード例 #1
0
        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();
        }
All Usage Examples Of Fun.FunapiNetwork::RegisterHandlerWithProtocol