12345678910111213141516171819202122232425262728293031323334 |
- namespace gameapi.Commands
- {
- public class WebsocketCommandFactory
- {
- public WebsocketCommandFactory()
- {
- }
- public IWebsocketCommand Create(string commandString)
- {
- var keys = commandString.Split(" ");
- switch (keys[0])
- {
- case "echo":
- return new EchoWebsocketCommand(commandString);
- case "ping":
- return new PongWebsocketCommand();
- case "join":
- return new JoinWebsocketCommand(keys);
- case "leave":
- return new LeaveWebsocketCommand(keys);
- case "move":
- return new MoveWebsocketCommand(keys);
- case "connect":
- return new ConnectWebsocketCommand(keys);
- case "disconnect":
- return new DisconnectWebsocketCommand(keys);
- default:
- return new UnknownWebsocketCommand();
- }
- }
- }
- }
|