summaryrefslogtreecommitdiff
path: root/server/src/network/index.ts
blob: 3cbf0acb3a54c120185afe56f76f252ad69ee9c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { Message } from '@engine/network';
import { Input } from '@engine/systems';

export * from './MessageProcessor';
export * from './MessagePublisher';
export * from './MessageReceiver';
export * from './SessionManager';
export * from './SessionInputSystem';

export type SessionData = { sessionId: string };

export type Session = {
  sessionId: string;
  controllableEntities: Set<string>;
  inputSystem: Input;
};

export interface ServerMessage extends Message {
  sessionData: SessionData;
}

export interface SessionManager {
  uniqueSessionId(): string;
  getSession(id: string): Session | undefined;
  getSessions(): string[];
  putSession(id: string, session: Session): void;
  removeSession(id: string): void;
  numSessions(): number;
}