Quantcast
Channel: GameDev.net
Viewing all articles
Browse latest Browse all 17625

Network Thread & Message Queue?

$
0
0

Hello everyone,

I'm struggling with some infrastructural logic hopefully you guys can give me a hand.

Given a single thread approach to networking, the sending and receiving is happening in the same loop. ( I'm using ENet ). The idea is I have a game thread that pulls from a message queue pushed by receive events and a loop inside of my network thread that pulls messages out of a queue pushed by my game thread.

Psuedo code:

NetworkThread()
{
	Messages[] messagesToSend;
	while(true)
	{
		Poll(event);

		if(event type == Receive)
			Game.Messages.Enqueue(event);

		//this loop is going to block my …

Viewing all articles
Browse latest Browse all 17625

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>