public bool JoinSession(string session) { AllJoyn.QStatus status = AllJoyn.QStatus.NONE; if (sessionListener != null) { status = msgBus.SetSessionListener(null, currentSessionId); sessionListener = null; if (!status) { Debug.LogError("SetSessionListener status(" + status.ToString() + ")"); } } sessionListener = new MySessionListener(this); //Debug.LogError("About to call JoinSession (Session=" + session + ")"); status = msgBus.JoinSession(session, SERVICE_PORT, sessionListener, out currentSessionId, opts); if (status) { //Debug.LogError("Client JoinSession SUCCESS (Session id=" + currentSessionId + ")"); currentJoinedSession = session; } else { //Debug.LogError("RHR JoinSession failed (status=" + status.ToString() + ")"); } return(status ? true : false); }
public void JoinSession(string session) { if (currentJoinedSession != null) { LeaveSession(); } AllJoyn.QStatus status = AllJoyn.QStatus.NONE; if (sessionListener != null) { status = msgBus.SetSessionListener(null, currentSessionId); sessionListener = null; if (!status) { chatText = "SetSessionListener failed status(" + status.ToString() + ")\n" + chatText; Debug.Log("SetSessionListener status(" + status.ToString() + ")"); } } sessionListener = new MySessionListener(); chatText = "About to call JoinSession (Session=" + session + ")\n" + chatText; Debug.Log("About to call JoinSession (Session=" + session + ")"); status = msgBus.JoinSession(session, SERVICE_PORT, sessionListener, out currentSessionId, opts); if (status) { chatText = "Client JoinSession SUCCESS (Session id=" + currentSessionId + ")\n" + chatText; Debug.Log("Client JoinSession SUCCESS (Session id=" + currentSessionId + ")"); currentJoinedSession = session; } else { chatText = "Chat JoinSession failed (status=" + status.ToString() + ")\n" + chatText; Debug.Log("Chat JoinSession failed (status=" + status.ToString() + ")"); } }
protected override void SessionJoined(ushort sessionPort, uint sessionId, string joiner) { Debug.Log("Session Joined!!!!!!"); chatText = "Session Joined!!!!!! \n" + chatText; currentSessionId = sessionId; currentJoinedSession = myAdvertisedName; if (sessionListener == null) { sessionListener = new MySessionListener(); msgBus.SetSessionListener(sessionListener, sessionId); } }
protected override void SessionJoined(ushort sessionPort, uint sessionId, string joiner) { //Debug.LogError("Session Joined!!!!!!"); currentSessionId = sessionId; currentJoinedSession = myAdvertisedName; multiplayerHandler.SetConnectedPlayerNick(joiner); multiplayerHandler.GameStarted(); if (sessionListener == null) { sessionListener = new MySessionListener(multiplayerHandler); msgBus.SetSessionListener(sessionListener, sessionId); } }
public void LeaveSession() { Debug.Log("in LeaveSession."); if (currentSessionId != 0) { AllJoyn.QStatus status = AllJoyn.QStatus.NONE; if (sessionListener != null) { Debug.Log("clear session listener"); status = msgBus.SetSessionListener(null, currentSessionId); sessionListener = null; if (!status) { chatText = "SetSessionListener failed status(" + status.ToString() + ")\n" + chatText; Debug.Log("SetSessionListener status(" + status.ToString() + ")"); } } Debug.Log("about to leave session"); status = msgBus.LeaveSession(currentSessionId); if (status) { chatText = "Chat LeaveSession SUCCESS (Session id=" + currentSessionId + ")\n" + chatText; Debug.Log("Chat LeaveSession SUCCESS (Session id=" + currentSessionId + ")"); currentSessionId = 0; currentJoinedSession = null; } else { chatText = "Chat LeaveSession failed (status=" + status.ToString() + ")\n" + chatText; Debug.Log("Chat LeaveSession failed (status=" + status.ToString() + ")"); } } else { currentJoinedSession = null; } Debug.Log("done LeaveSession."); }
public void CloseDown() { if(msgBus == null) return; //no need to clean anything up AllJoynStarted = false; LeaveSession(); AllJoyn.QStatus status = msgBus.CancelFindAdvertisedName(SERVICE_NAME); if(!status) { chatText = "CancelAdvertisedName failed status(" + status.ToString() + ")\n" + chatText; Debug.Log("CancelAdvertisedName failed status(" + status.ToString() + ")"); } status = msgBus.CancelAdvertisedName(myAdvertisedName, opts.Transports); if(!status) { chatText = "CancelAdvertisedName failed status(" + status.ToString() + ")\n" + chatText; Debug.Log("CancelAdvertisedName failed status(" + status.ToString() + ")"); } status = msgBus.ReleaseName(myAdvertisedName); if(!status) { chatText = "ReleaseName failed status(" + status.ToString() + ")\n" + chatText; Debug.Log("ReleaseName status(" + status.ToString() + ")"); } status = msgBus.UnbindSessionPort(SERVICE_PORT); if(!status) { chatText = "UnbindSessionPort failed status(" + status.ToString() + ")\n" + chatText; Debug.Log("UnbindSessionPort status(" + status.ToString() + ")"); } status = msgBus.Disconnect(connectedVal); if(!status) { chatText = "Disconnect failed status(" + status.ToString() + ")\n" + chatText; Debug.Log("Disconnect status(" + status.ToString() + ")"); } AllJoyn.InterfaceDescription.Member chatMember = testIntf.GetMember("chat"); status = msgBus.UnregisterSignalHandler(this.ChatSignalHandler, chatMember, null); chatMember = null; if(!status) { chatText = "UnregisterSignalHandler failed status(" + status.ToString() + ")\n" + chatText; Debug.Log("UnregisterSignalHandler status(" + status.ToString() + ")"); } if(sessionListener != null) { status = msgBus.SetSessionListener(null, currentSessionId); sessionListener = null; if(!status) { chatText = "SetSessionListener failed status(" + status.ToString() + ")\n" + chatText; Debug.Log("SetSessionListener status(" + status.ToString() + ")"); } } chatText = "No Exceptions(" + status.ToString() + ")\n" + chatText; Debug.Log("No Exceptions(" + status.ToString() + ")"); currentSessionId = 0; currentJoinedSession = null; sFoundName.Clear(); connectedVal = null; msgBus = null; busListener = null; sessionPortListener = null; testObj = null; testIntf = null; opts = null; myAdvertisedName = null; AllJoynStarted = false; AllJoyn.StopAllJoynProcessing(); //Stop processing alljoyn callbacks }
protected override void SessionJoined(ushort sessionPort, uint sessionId, string joiner) { Debug.Log("Session Joined!!!!!!"); chatText = "Session Joined!!!!!! \n" + chatText; currentSessionId = sessionId; currentJoinedSession = myAdvertisedName; if(sessionListener == null) { sessionListener = new MySessionListener(); msgBus.SetSessionListener(sessionListener, sessionId); } }
public void LeaveSession() { Debug.Log("in LeaveSession."); if(currentSessionId != 0) { AllJoyn.QStatus status = AllJoyn.QStatus.NONE; if(sessionListener != null) { Debug.Log("clear session listener"); status = msgBus.SetSessionListener(null, currentSessionId); sessionListener = null; if(!status) { chatText = "SetSessionListener failed status(" + status.ToString() + ")\n" + chatText; Debug.Log("SetSessionListener status(" + status.ToString() + ")"); } } Debug.Log("about to leave session"); status = msgBus.LeaveSession(currentSessionId); if(status) { chatText = "Chat LeaveSession SUCCESS (Session id=" + currentSessionId + ")\n" + chatText; Debug.Log("Chat LeaveSession SUCCESS (Session id=" + currentSessionId + ")"); currentSessionId = 0; currentJoinedSession = null; } else { chatText = "Chat LeaveSession failed (status=" + status.ToString() + ")\n" + chatText; Debug.Log("Chat LeaveSession failed (status=" + status.ToString() + ")"); } } else { currentJoinedSession = null; } Debug.Log("done LeaveSession."); }
public void JoinSession(string session) { if(currentJoinedSession != null) LeaveSession(); AllJoyn.QStatus status = AllJoyn.QStatus.NONE; if(sessionListener != null) { status = msgBus.SetSessionListener(null, currentSessionId); sessionListener = null; if(!status) { chatText = "SetSessionListener failed status(" + status.ToString() + ")\n" + chatText; Debug.Log("SetSessionListener status(" + status.ToString() + ")"); } } sessionListener = new MySessionListener(); chatText = "About to call JoinSession (Session=" + session + ")\n" + chatText; Debug.Log("About to call JoinSession (Session=" + session + ")"); status = msgBus.JoinSession(session, SERVICE_PORT, sessionListener, out currentSessionId, opts); if(status) { chatText = "Client JoinSession SUCCESS (Session id=" + currentSessionId + ")\n" + chatText; Debug.Log("Client JoinSession SUCCESS (Session id=" + currentSessionId + ")"); currentJoinedSession = session; } else { chatText = "Chat JoinSession failed (status=" + status.ToString() + ")\n" + chatText; Debug.Log("Chat JoinSession failed (status=" + status.ToString() + ")"); } }
public void CloseDown() { if (msgBus == null) { return; //no need to clean anything up } AllJoynStarted = false; LeaveSession(); AllJoyn.QStatus status = msgBus.CancelFindAdvertisedName(SERVICE_NAME); if (!status) { chatText = "CancelAdvertisedName failed status(" + status.ToString() + ")\n" + chatText; Debug.Log("CancelAdvertisedName failed status(" + status.ToString() + ")"); } status = msgBus.CancelAdvertisedName(myAdvertisedName, opts.Transports); if (!status) { chatText = "CancelAdvertisedName failed status(" + status.ToString() + ")\n" + chatText; Debug.Log("CancelAdvertisedName failed status(" + status.ToString() + ")"); } status = msgBus.ReleaseName(myAdvertisedName); if (!status) { chatText = "ReleaseName failed status(" + status.ToString() + ")\n" + chatText; Debug.Log("ReleaseName status(" + status.ToString() + ")"); } status = msgBus.UnbindSessionPort(SERVICE_PORT); if (!status) { chatText = "UnbindSessionPort failed status(" + status.ToString() + ")\n" + chatText; Debug.Log("UnbindSessionPort status(" + status.ToString() + ")"); } status = msgBus.Disconnect(connectedVal); if (!status) { chatText = "Disconnect failed status(" + status.ToString() + ")\n" + chatText; Debug.Log("Disconnect status(" + status.ToString() + ")"); } AllJoyn.InterfaceDescription.Member chatMember = testIntf.GetMember("chat"); status = msgBus.UnregisterSignalHandler(this.ChatSignalHandler, chatMember, null); chatMember = null; if (!status) { chatText = "UnregisterSignalHandler failed status(" + status.ToString() + ")\n" + chatText; Debug.Log("UnregisterSignalHandler status(" + status.ToString() + ")"); } if (sessionListener != null) { status = msgBus.SetSessionListener(null, currentSessionId); sessionListener = null; if (!status) { chatText = "SetSessionListener failed status(" + status.ToString() + ")\n" + chatText; Debug.Log("SetSessionListener status(" + status.ToString() + ")"); } } chatText = "No Exceptions(" + status.ToString() + ")\n" + chatText; Debug.Log("No Exceptions(" + status.ToString() + ")"); currentSessionId = 0; currentJoinedSession = null; sFoundName.Clear(); connectedVal = null; msgBus = null; busListener = null; sessionPortListener = null; testObj = null; testIntf = null; opts = null; myAdvertisedName = null; AllJoynStarted = false; AllJoyn.StopAllJoynProcessing(); //Stop processing alljoyn callbacks }
public void CloseDown() { if (msgBus == null) return; AllJoynStarted = false; LeaveSession(); AllJoyn.QStatus status = msgBus.CancelFindAdvertisedName(SERVICE_NAME); if (!status){ DebugLog("CancelAdvertisedName failed status(" + status.ToString() + ")"); } status = msgBus.CancelAdvertisedName(myAdvertisedName, opts.Transports); if (!status) { DebugLog("CancelAdvertisedName failed status(" + status.ToString() + ")"); } status = msgBus.ReleaseName(myAdvertisedName); if (!status) { DebugLog("ReleaseName status(" + status.ToString() + ")"); } status = msgBus.UnbindSessionPort(SERVICE_PORT); if (!status) { DebugLog("UnbindSessionPort status(" + status.ToString() + ")"); } status = msgBus.Disconnect(connectedVal); if (!status) { DebugLog("Disconnect status(" + status.ToString() + ")"); } AllJoyn.InterfaceDescription.Member vectorMember = testIntf.GetMember("vector"); status = msgBus.UnregisterSignalHandler(this.VectorSignalHandler, vectorMember, null); vectorMember = null; if (!status) { DebugLog("UnregisterSignalHandler Vector status(" + status.ToString() + ")"); } if (sessionListener != null) { status = msgBus.SetSessionListener(null, currentSessionId); sessionListener = null; if (!status) { DebugLog("SetSessionListener status(" + status.ToString() + ")"); } } DebugLog("No Exceptions(" + status.ToString() + ")"); currentSessionId = 0; currentJoinedSession = null; sFoundName.Clear(); connectedVal = null; msgBus = null; busListener = null; sessionPortListener = null; testObj = null; testIntf = null; opts = null; myAdvertisedName = null; AllJoynStarted = false; sFoundName = new ArrayList(); AllJoyn.StopAllJoynProcessing(); }
protected override void SessionJoined(ushort sessionPort, uint sessionId, string joiner) { DebugLog("Session Joined!!!!!!"); currentSessionId = sessionId; currentJoinedSession = myAdvertisedName; multiplayerHandler.SetConnectedPlayerNick(joiner); multiplayerHandler.GameStarted(); if(sessionListener == null) { sessionListener = new MySessionListener(multiplayerHandler); msgBus.SetSessionListener(sessionListener, sessionId); } }
public bool JoinSession(string session) { if (currentJoinedSession != null) LeaveSession(); AllJoyn.QStatus status = AllJoyn.QStatus.NONE; if (sessionListener != null) { status = msgBus.SetSessionListener(null, currentSessionId); sessionListener = null; if (!status) { DebugLog("SetSessionListener status(" + status.ToString() + ")"); } } sessionListener = new MySessionListener(this); DebugLog("About to call JoinSession (Session=" + session + ")"); status = msgBus.JoinSession(session, SERVICE_PORT, sessionListener, out currentSessionId, opts); if(status) { DebugLog("Client JoinSession SUCCESS (Session id=" + currentSessionId + ")"); currentJoinedSession = session; } else { DebugLog("RHR JoinSession failed (status=" + status.ToString() + ")"); } return status ? true : false; }