public static bool Install(ArgumentMap arguments) { // 세션 열림 및 닫힘 핸들러를 등록합니다. NetworkHandlerRegistry.RegisterSessionHandler( new NetworkHandlerRegistry.SessionOpenedHandler(OnSessionOpened), new NetworkHandlerRegistry.SessionClosedHandler(OnSessionClosed)); // TCP 연결이 끊어졌을 때 호출할 핸들러를 등록합니다. 세션이 닫힌 건 아니므로 // 언제든지 다른 트랜스포트를 통해 이 세션을 사용할 수 있습니다. // (WIFI -> LTE 이동과 같은 상황이 좋은 예입니다) NetworkHandlerRegistry.RegisterTcpTransportDetachedHandler(OnTcpTransportDetached); // 로그인 요청 핸들러를 등록합니다. NetworkHandlerRegistry.RegisterMessageHandler( kLoginMessage, new NetworkHandlerRegistry.JsonMessageHandler(OnLoginRequest)); // 로그아웃 요청 핸들러를 등록합니다 NetworkHandlerRegistry.RegisterMessageHandler( kLogoutMessage, new NetworkHandlerRegistry.JsonMessageHandler(OnLogoutRequest)); // 매치메이킹 후 매치가 성사된 유저들을 모아 데디케이티드 서버를 스폰합니다. NetworkHandlerRegistry.RegisterMessageHandler( kMatchThenSpawnMessage, new NetworkHandlerRegistry.JsonMessageHandler(OnMatchThenSpawnRequest)); // 매치메이킹 요청을 취소합니다. NetworkHandlerRegistry.RegisterMessageHandler( kCancelMatchMessage, new NetworkHandlerRegistry.JsonMessageHandler(OnCancelMatchRequest)); // 데디케이티드 서버 생성이 완료된 클라이언트로 // 스폰 결과에 대한 응답을 보낼 때 사용합니다. DedicatedServerHelper.Install(OnDedicatedServerSpawned); // 매치매이킹 서버가 내부적으로 쓰는 핸들러들을 등록합니다. MatchmakingServerWrapper.Install(); return(true); }
public static void Install() { Session.EncodingScheme encoding = Session.EncodingScheme.kUnknownEncoding; UInt64 tcp_json_port = Flags.GetUInt64("tcp_json_port"); UInt64 udp_json_port = Flags.GetUInt64("udp_json_port"); UInt64 http_json_port = Flags.GetUInt64("http_json_port"); UInt64 websocket_json_port = Flags.GetUInt64("websocket_json_port"); UInt64 tcp_protobuf_port = Flags.GetUInt64("tcp_protobuf_port"); UInt64 udp_protobuf_port = Flags.GetUInt64("udp_protobuf_port"); UInt64 http_protobuf_port = Flags.GetUInt64("http_protobuf_port"); UInt64 websocket_protobuf_port = Flags.GetUInt64("websocket_protobuf_port"); if (tcp_json_port != 0 || udp_json_port != 0 || http_json_port != 0 || websocket_json_port != 0) { encoding = Session.EncodingScheme.kJsonEncoding; } if (tcp_protobuf_port != 0 || udp_protobuf_port != 0 || http_protobuf_port != 0 || websocket_protobuf_port != 0) { if (encoding != Session.EncodingScheme.kUnknownEncoding) { Log.Fatal("Cannot set both JSON and Protobuf. Enable only one in MANIFEST.game.json"); } encoding = Session.EncodingScheme.kProtobufEncoding; } if (encoding == Session.EncodingScheme.kUnknownEncoding) { Log.Fatal("Either JSON or Protobuf must be enabled."); } NetworkHandlerRegistry.RegisterSessionHandler( new NetworkHandlerRegistry.SessionOpenedHandler(OnSessionOpened), (_1, _2) => { OnSessionClosed(_1, _2, encoding); }); NetworkHandlerRegistry.RegisterTcpTransportDetachedHandler((_1) => { OnTcpDisconnected(_1, encoding); }); NetworkHandlerRegistry.RegisterWebSocketTransportDetachedHandler((_1) => { OnWebSocketDisconnected(_1, encoding); }); // for json NetworkHandlerRegistry.RegisterMessageHandler("ready", new NetworkHandlerRegistry.JsonMessageHandler(OnReady)); NetworkHandlerRegistry.RegisterMessageHandler("relay", new NetworkHandlerRegistry.JsonMessageHandler(OnRelay)); NetworkHandlerRegistry.RegisterMessageHandler("result", new NetworkHandlerRegistry.JsonMessageHandler(OnResult)); // for pbuf NetworkHandlerRegistry.RegisterMessageHandler("ready", new NetworkHandlerRegistry.ProtobufMessageHandler(OnReady2)); NetworkHandlerRegistry.RegisterMessageHandler("relay", new NetworkHandlerRegistry.ProtobufMessageHandler(OnRelay2)); NetworkHandlerRegistry.RegisterMessageHandler("result", new NetworkHandlerRegistry.ProtobufMessageHandler(OnResult2)); }
public static void Install() { NetworkHandlerRegistry.RegisterSessionHandler(new NetworkHandlerRegistry.SessionOpenedHandler(OnSessionOpened), new NetworkHandlerRegistry.SessionClosedHandler(OnSessionClosed)); NetworkHandlerRegistry.RegisterTcpTransportDetachedHandler(new NetworkHandlerRegistry.TcpTransportDetachedHandler(OnTcpDisconnected)); // for json NetworkHandlerRegistry.RegisterMessageHandler("login", new NetworkHandlerRegistry.JsonMessageHandler(OnLogin)); NetworkHandlerRegistry.RegisterMessageHandler("singleresult", new NetworkHandlerRegistry.JsonMessageHandler(OnSingleModeResultReceived)); NetworkHandlerRegistry.RegisterMessageHandler("match", new NetworkHandlerRegistry.JsonMessageHandler(OnMatchmaking)); NetworkHandlerRegistry.RegisterMessageHandler("cancelmatch", new NetworkHandlerRegistry.JsonMessageHandler(OnCancelMatchmaking)); NetworkHandlerRegistry.RegisterMessageHandler("ranklist", new NetworkHandlerRegistry.JsonMessageHandler(OnRanklistRequested)); NetworkHandlerRegistry.RegisterMessageHandler("ranklist_single", new NetworkHandlerRegistry.JsonMessageHandler(OnSingleRanklistRequested)); // for pbuf NetworkHandlerRegistry.RegisterMessageHandler("login", new NetworkHandlerRegistry.ProtobufMessageHandler(OnLogin2)); NetworkHandlerRegistry.RegisterMessageHandler("singleresult", new NetworkHandlerRegistry.ProtobufMessageHandler(OnSingleModeResultReceived2)); NetworkHandlerRegistry.RegisterMessageHandler("match", new NetworkHandlerRegistry.ProtobufMessageHandler(OnMatchmaking2)); NetworkHandlerRegistry.RegisterMessageHandler("cancelmatch", new NetworkHandlerRegistry.ProtobufMessageHandler(OnCancelMatchmaking2)); NetworkHandlerRegistry.RegisterMessageHandler("ranklist", new NetworkHandlerRegistry.ProtobufMessageHandler(OnRanklistRequested2)); NetworkHandlerRegistry.RegisterMessageHandler("ranklist_single", new NetworkHandlerRegistry.ProtobufMessageHandler(OnSingleRanklistRequested2)); }