// Helper method used for testing. public RoomPresence generateRoomPresence() { RoomPresence retVal = new RoomPresence(); retVal.sensor = sensorId; retVal.room = DateTime.Now.Millisecond.ToString(); retVal.timeStamp = DateTime.Now; //roomPresence = retVal; return(retVal); }
private XmlElement CreateJoinPresence(XmlElement elem, RoomStatus[] statuses) { XmlDocument myDoc = new XmlDocument(); RoomPresence presence = new RoomPresence(myDoc, jid); presence.RemoveAll(); presence.From = elem.GetAttribute("to"); UserX xElem = new UserX(myDoc); presence.AppendChild(xElem); xElem.Status = statuses; return(presence); }
// Establishing connection, creating hub proxy and defining method that server can call. If flag is true invoke the broadcast public async void StartHub(RoomPresence testObject, bool flag) { var hubConnection = new HubConnection("http://localhost:8080"); IHubProxy serverHubProxy = hubConnection.CreateHubProxy("ServerHub"); serverHubProxy.On <RoomPresence>("broadcast", roomPresence => Console.WriteLine("Sensor '{0}' is in the room '{1}' on time: {2}", roomPresence.sensor, roomPresence.room, roomPresence.timeStamp)); await hubConnection.Start(); hubConnection.Error += ex => Console.WriteLine("SignalR error: {0}", ex.Message); // Invoking method on server if (flag) { await serverHubProxy.Invoke("broadcastPositions", testObject); } }
private XmlElement CreateUnavailPacket(XmlElement elem) { XmlDocument myDoc = new XmlDocument(); RoomPresence presence = new RoomPresence(myDoc, jid); presence.RemoveAll(); presence.Type = PresenceType.unavailable; presence.From = elem.GetAttribute("to"); UserX xElem = new UserX(myDoc); presence.AppendChild(xElem); xElem.Status = new RoomStatus[] { RoomStatus.SELF }; return(presence); }
/// <summary> /// Join a room, using a password. /// </summary> /// <param name="password"></param> public void Join(string password) { if (m_state == STATE.running) return; m_state = STATE.join; RoomPresence pres = new RoomPresence(m_manager.Stream.Document, m_jid); if (password != null) pres.X.Password = password; m_manager.Write(pres); }
/// <summary> /// Joins the room. If the room is created, Configure() will /// be called automatically. /// </summary> public void Join() { if (m_state == STATE.running) return; m_state = STATE.join; RoomPresence pres = new RoomPresence(m_stream.Document, m_jid); m_stream.Write(pres); }
private XmlElement CreateUnavailPacket(XmlElement elem) { XmlDocument myDoc = new XmlDocument(); RoomPresence presence = new RoomPresence(myDoc, jid); presence.RemoveAll(); presence.Type = PresenceType.unavailable; presence.From = elem.GetAttribute("to"); UserX xElem = new UserX(myDoc); presence.AppendChild(xElem); xElem.Status = new RoomStatus[] { RoomStatus.SELF }; return presence; }
private XmlElement CreateJoinPresence(XmlElement elem, RoomStatus[] statuses) { XmlDocument myDoc = new XmlDocument(); RoomPresence presence = new RoomPresence(myDoc, jid); presence.RemoveAll(); presence.From = elem.GetAttribute("to"); UserX xElem = new UserX(myDoc); presence.AppendChild(xElem); xElem.Status = statuses; return presence; }