public GameLoop CreateGameLoop() { if (threadStarter == null) { throw new InvalidOperationException(string.Format("Missing {0}", typeof(IThreadStarter).FullName)); } // Validate that we have gotten all the external settings needed. Like configuration file, communicator template/factory, ... IContext messageContext = CreateMessageContext(); IRemoteCommunicator communicator = CreateContextCommunicator(); RemoteDispatcherProxy remoteProxy = CreateRemoteDispatcher(messageContext, communicator); return(new GameLoop(messageContext, remoteProxy)); }
private RemoteDispatcherProxy CreateRemoteDispatcher(IContext context, IRemoteCommunicator communicator) { RemoteDispatcherProxy proxy = new RemoteDispatcherProxy(context.Dispatcher, context.Serializer, communicator); return(proxy); }
private static RemoteDispatcherProxy CreateRemoteDispatcher(IContext context, IRemoteCommunicator communicator) { RemoteDispatcherProxy proxy = new RemoteDispatcherProxy(context.Dispatcher, context.Serializer, communicator); //WriterListener listener = new WriterListener(); //context.Dispatcher.RegisterListenerForAll(listener); return(proxy); }
public RemoteDispatcherProxy(IDispatcher localDispatcher, ISerializer serializer, IRemoteCommunicator remoteCommunicator) { this.LocalDispatcher = localDispatcher; this.Serializer = serializer; this.RemoteCommunicator = remoteCommunicator; messageBuffer = new List <IMessage> [2]; messageBuffer[0] = new List <IMessage>(); messageBuffer[1] = new List <IMessage>(); messageBufferIndex = 0; messageWaiting = false; messageBufferLock = new object(); outgoingStream = new MemoryStream(); LocalDispatcher.RegisterListenerForAll(this); LocalDispatcher.AddToForwardIgnoreList(this); RemoteCommunicator.RegisterReceiver(ReceiveRemoteMessage); }