void OnApplicationQuit() { AllJoyn.StopAllJoynProcessing(); }
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 }