private void Start() { link = GetComponent <ClientsideLink>(); sessions = new ClientsideSessions(link); link.AttemptConnection(success => { if (success) { sessions.DoLogin("droqen"); } else { Dj.Warnf("Login failed. TODO: Implement retry"); } }); sessions.AddStoryfan(Session.OPCODE, new LambdaStoryfan <Session>(session => { if (currentSession == null || currentSession.Username != session.Username) { currentSession = session; link.Post <OK>(RequestStories.OPCODE, new RequestStories { message = "Hello from " + currentSession.Username, }, reply => { }, failStatus => { Dj.Tempf("RequestStories rejected with status {0}. Recommended to either request again, or disconnect.", failStatus); }); } Dj.Tempf("My session says my name is '{0}'", currentSession.Username); })); sessions.AddStoryfan(TowerZone.OPCODE, new LambdaStoryfan <TowerZone>(zone => { currentZone = zone; visibleEntities.Clear(); })); sessions.AddStoryfan(TowerEntity.OPCODE, new LambdaStoryfan <TowerEntity>(ent => { bool its_me = false; try { if (currentSession.EntityId == ent.EntityId) { myEntity = ent; its_me = true; } } catch { } if (!its_me) { if (ent.WorldPos == currentZone.WorldPos) { visibleEntities.Add(ent); } else { visibleEntities.Remove(ent); } } })); sessions.PushStorydecoder(new TowerStoryDecoder()); }
public void AttemptConnection() { link.AttemptConnection(success => { xxi.RefreshClientView(); }); }