protected void DoAccept(RCRunner runner, RCClosure closure, RCLong left, RCLong right) { RCBot bot = runner.GetBot(closure.Bot); for (int i = 0; i < left.Count; ++i) { Server server = (Server)bot.Get(left[i]); server.Accept(runner, closure, right[0]); } }
protected void DoReceive(RCRunner runner, RCClosure closure, RCSymbol right) { RCBot bot = runner.GetBot(closure.Bot); TcpCollector gatherer = new TcpCollector(runner, closure, right); for (int i = 0; i < right.Count; ++i) { long channel = (long)right[i].Part(0); Client client = (Client)bot.Get(channel); client.Receive(gatherer, right[i]); } }
protected void DoSend(RCRunner runner, RCClosure closure, RCLong left, RCBlock right) { RCSymbolScalar[] result = new RCSymbolScalar[left.Count]; RCBot bot = runner.GetBot(closure.Bot); for (int i = 0; i < left.Count; ++i) { Client client = (Client)bot.Get(left[i]); TcpSendState state = client.Send(runner, closure, right); RCSymbolScalar handle = new RCSymbolScalar(null, state.Handle); result[i] = new RCSymbolScalar(handle, state.Id); } runner.Yield(closure, new RCSymbol(result)); }
public void EvalClose(RCRunner runner, RCClosure closure, RCLong right) { // Implementing multiple would require some annoying scatter gather logic. // Plus what if one fails out of the list? if (right.Count != 1) { throw new Exception("open takes exactly one protocol,host,port"); } RCBot bot = runner.GetBot(closure.Bot); Client client = (Client)bot.Get(right[0]); client.Close(runner, closure); runner.Yield(closure, right); }
protected void DoReply(RCRunner runner, RCClosure closure, RCSymbol left, RCBlock right) { RCBot bot = runner.GetBot(closure.Bot); RCSymbolScalar[] result = new RCSymbolScalar[left.Count]; for (int i = 0; i < left.Count; ++i) { long channel = (long)left[i].Part(0); long sid = (long)left[i].Part(1); long cid = (long)left[i].Part(2); Server server = (Server)bot.Get(channel); TcpSendState state = server.Reply(runner, closure, sid, cid, right); RCSymbolScalar handle = new RCSymbolScalar(null, state.Handle); result[i] = new RCSymbolScalar(handle, state.Id); } runner.Yield(closure, new RCSymbol(result)); }