@game-vir/multiplayer-server - v15.1.1
    Preparing search index...

    Function implementMultiplayerService

    • Implements the multiplayer server.

      Parameters

      Returns {
          serverState: MultiplayerServerState;
          service: ServiceImplementation<
              NoInfer<{ gameId: string }>,
              "multiplayer-service",
              {
                  "/": {
                      methods: { GET: true };
                      requestDataShape: undefined;
                      requiredClientOrigin: { anyOrigin: boolean };
                      responseDataShape: ShapeExact<readonly ["ok"]>;
                  };
                  "/health": {
                      methods: { GET: true };
                      requestDataShape: undefined;
                      requiredClientOrigin: { anyOrigin: boolean };
                      responseDataShape: ShapeExact<readonly ["ok"]>;
                  };
                  "/rooms": {
                      methods: { GET: true };
                      requestDataShape: undefined;
                      responseDataShape: ShapeDefinition<
                          ShapeIndexedKeys<
                              [
                                  {
                                      keys: CustomSpecifier<
                                          `${string}-${string}-${string}-${string}-${string}`,
                                      >;
                                      required: false;
                                      values: ShapeDefinition<
                                          {
                                              clientCount: number;
                                              hasRoomPassword: boolean;
                                              roomId: CustomSpecifier<(...)>;
                                              roomName: string;
                                          },
                                          false,
                                      >;
                                  },
                              ],
                          >,
                          false,
                      >;
                      searchParamsShape: { gameId: ShapeTuple<[string]> };
                  };
              },
              {
                  "/connect": {
                      messageFromClientShape: ShapeOr<
                          [
                              ShapeDefinition<
                                  ShapeAnd<
                                      [
                                          ShapeDefinition<
                                              { clientId: ...; roomId: ...; roomName: ... },
                                              false,
                                          >,
                                          ShapeDefinition<{ messageId: ... }, false>,
                                          { data: ShapeOr<(...)>; type: ShapeExact<(...)> },
                                      ],
                                  >,
                                  false,
                              >,
                              ShapeDefinition<
                                  ShapeAnd<
                                      [
                                          ShapeDefinition<ShapeAnd<(...)>, false>,
                                          ShapeDefinition<{ messageId: ... }, false>,
                                          { clientSecret: string; roomPassword: string },
                                      ],
                                  >,
                                  false,
                              >,
                              ShapeDefinition<
                                  ShapeAnd<
                                      [
                                          ShapeDefinition<
                                              { clientId: ...; roomId: ...; roomName: ... },
                                              false,
                                          >,
                                          ShapeDefinition<{ messageId: ... }, false>,
                                          {
                                              clientCount: number;
                                              clientSecret: string;
                                              roomPassword: string;
                                              type: ShapeExact<(...)>;
                                          },
                                      ],
                                  >,
                                  false,
                              >,
                          ],
                      >;
                      messageFromHostShape: ShapeOr<
                          [
                              ShapeDefinition<
                                  ShapeAnd<
                                      [
                                          ShapeDefinition<
                                              { clientId: ...; roomId: ...; roomName: ... },
                                              false,
                                          >,
                                          ShapeDefinition<{ messageId: ... }, false>,
                                          { data: ShapeOr<(...)>; type: ShapeExact<(...)> },
                                      ],
                                  >,
                                  false,
                              >,
                              ShapeDefinition<
                                  ShapeAnd<
                                      [
                                          ShapeDefinition<
                                              { clientId: ...; roomId: ...; roomName: ... },
                                              false,
                                          >,
                                          ShapeDefinition<{ messageId: ... }, false>,
                                          { data: ShapeDefinition<(...), (...)>; type: ShapeExact<(...)> },
                                      ],
                                  >,
                                  false,
                              >,
                              ShapeDefinition<
                                  ShapeAnd<
                                      [
                                          ShapeDefinition<{ messageId: ... }, false>,
                                          { hostClientId: CustomSpecifier<(...)>; type: ShapeExact<(...)> },
                                      ],
                                  >,
                                  false,
                              >,
                              ShapeDefinition<
                                  ShapeAnd<
                                      [
                                          ShapeDefinition<{ messageId: ... }, false>,
                                          { errorMessage: string; type: ShapeExact<(...)> },
                                      ],
                                  >,
                                  false,
                              >,
                          ],
                      >;
                      searchParamsShape: { gameId: ShapeTuple<[string]> };
                  };
              },
          >;
      }