static Lobby() { State state = ServerState.stateLobby; state.Register((Protocol.Login p, Lobby m, SID sid) => { User user = new User(); user.id = UID.Alloc(m.maxuid, m.users.Keys); user.name = p.name; user.sid = sid; m.users.Add(user.id, user); m.sessions[sid].Add(user.id); Protocol.LoginRe re = new Protocol.LoginRe(); re.ret = 0; re.self = user.id; m.Send(sid, re); }); Register(state, (Protocol.Logout q, Protocol.LogoutRe r, User a, Lobby m, SID sid) => { m.users.Remove(q.self); return(0); }); Register(state, (Protocol.Join q, Protocol.JoinRe r, User a, Lobby m, SID sid) => { Pen pen; if (!m.pens.TryGetValue(q.pen, out pen)) { pen = new Pen(); m.pens.Add(q.pen, pen); } //TODO pen.AddUser(a); return(0); }); }