7

I am facing a problem with architectural assumptions. Little background: I am writing a game server that can create rooms for specified players and within that room(websocket) the server is listening for any event (e.g loss of player, internet disconnection etc.). Wholeness will be scalable so multiple Tomcat nodes will be deployed under some LB supervision. At the moment I have figured out the process as(remember about tomcat cluster):

  1. Client is logging to GameServer via REST API, the session is saved in RedisDB shared between all nodes. Server returns HTTP 200.

  2. Client is logged in the system and he decided to search for a game. The "/search/game" endpoint is invoked.

    2.1. The System handles user request and adds player to temp Queue which is RedisDB(next or same instance not sure about that now), and returns HTTP 200 to client.

  3. Scheduler on one specific node runs every 10-20sec. and looks if RedisDB has any records, if it is true, then server keeps juxtaposing players and creates game rooms for them untill RedisDB is empty or has odd player.

I was not sure how to juxtaposes specific players within websocket and make it visible for other nodes. I have googled a while and found smiliar example on

stack: Spring Websocket in a tomcat cluster

where user Thanh Nguyen Van mentioned two ways for handling websockets traffic over multiple tomcat instances so I have decided to use Apache ActiveMq JMS and Apache Camel as a handling websockets traffic solution.

I have successfully implemented it on sandbox app, where 3 different users can log into system and send a private message to each other. Whole implemented with ActiveMq, Camel, STOMP, SockJS and Spring Boot. Fair enough... but this is the part I am stuck on. I feel like I've got all the blocks I need but I can't put it all together.

First of all, I am not sure if the given process is suitable for presented problem. I Am thinking about points 2 and 3 and instead of invoking REST endpoint and adding players to RedisDB as a queue buffer maybe I should create a websocket between players(but how players would know the game websocket endpoint? Another temp buffer queue?) And how to detect any incoming events from clients e.g internet disconnection / game loos within GameRoom socket? Or maybe I am facing a problem from wrong side, maybe there are better tools for handling websocket traffic over multiple tomcat instance besides from ActiveMQ and Apache Camel in Spring ecosystem?

11thdimension
  • 10,333
  • 4
  • 33
  • 71
Bnq
  • 119
  • 9

0 Answers0