12345678910111213141516171819202122232425262728293031323334 |
- namespace gameapi.Commands
- {
- public class WebsocketCommandFactory
- {
- public WebsocketCommandFactory()
- {
- }
- public IWebsocketCommand Create(string commandString)
- {
- var keys = commandString.Split(" ");
- switch (keys[0])
- {
- case "connect":
- return new ConnectWebsocketCommand(keys);
- case "disconnect":
- return new DisconnectWebsocketCommand(keys);
- 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);
- default:
- return new UnknownWebsocketCommand();
- }
- }
- }
- }
|