http and udp code need to stay together
No they don't. They are transport mechanisms for your game data, so they should be transparent. Your UDP and HTTP servers should connect to your game backend, in what way is up to you. It can be in-memory, by using HTTP and UDP (socket) modules directly from your backend code, or it could be using some sort of service (so you can let other channels talk to the same backend).
This game backend does not connect directly to the user but only talks to the UDP and HTTP modules.
Then from this backend you process messages you receive from both HTTP and UDP, and sends the response over the same channel.
Example:
- AIR-client 1 sends a valid login message to UDP server.
- UDP server forwards the login message to the game backend.
- Game backend returns succesful result message to UDP server
- UDP server forwards the result message to AIR-client 1.
Example 2:
- Now HTTP-client 1, which happens to be already logged in, requests all users currently logged in. It does so over HTTP, to the HTTP server.
- HTTP server forwards this request to the game backend.
- Game backend returns information to HTTP server
- HTTP server returns response to client.