static void Main(string[] args) { string apiKey = "(api-key)"; string secret = "(secret)"; var rtmAuthorizer = new RtmAuthorizer(apiKey, secret); string frob = rtmAuthorizer.GetFrob().First(); string authenticationUrl = rtmAuthorizer.GetAuthenticationUrl(frob); //Process.Start(authenticationUrl); //Console.WriteLine("Webページで認証してください。..."); //Console.ReadKey(); //var token = rtmAuthorizer.GetToken(frob).First(); //Console.WriteLine("Token:{0}", token.Token); RtmClient client = new RtmClient(apiKey, secret, "(token)"); var lists = client.GetLists(); var list = lists.First(); }
public async Task Init(Context context, string userId) { _context = context; _agoraRtmHandler = new AgoraRtmHandler(); _agoraRtmHandler.OnSignalReceived += (signal) => { Log($"Signal received from {signal.RtcPeerId}"); OnSignalReceived?.Invoke(signal); }; _rtmClient = RtmClient.CreateInstance(_context, AgoraTestConstants.AgoraAPI, _agoraRtmHandler); var rtmToken = await AgoraTokenService.GetRtmToken(userId); var loginCallback = new ResultCallback(); loginCallback.OnSuccessAction += (obj) => { UserName = userId; OnLogin?.Invoke(true); Log("Login Success"); }; loginCallback.OnFailureAction += (err) => { OnLogin?.Invoke(false); Log("Login Fail"); }; _rtmClient.Login(rtmToken, userId, loginCallback); }
public void Init() { string appID = _context.GetString(Resource.String.agora_app_id); _myRtmClientListener = new RtmClientListener(); _myRtmClientListener.MessageReceived += OnRtmMessageReceived; _myRtmClientListener.StateChanged += OnStateChanged; try { _rtmClient = RtmClient.CreateInstance(_context, appID, _myRtmClientListener); #if DEBUG _rtmClient.SetParameters("{\"rtm.log_filter\": 65535}"); #endif } catch (Exception e) { throw new Exception($"NEED TO check rtm sdk init fatal error\n {e.StackTrace}"); } _callManager = _rtmClient.RtmCallManager; _callManager.RemoteInvitationReceived += RemoteInvitationReceived; _callManager.RemoteInvitationFailure += RemoteInvitationFailure; _callManager.LocalInvitationReceivedByPeer += LocalInvitationReceivedByPeer; _callManager.RemoteInvitationAccepted += RemoteInvitationAccepted; _callManager.RemoteInvitationRefused += RemoteInvitationRefused; _callManager.LocalInvitationRefused += LocalInvitationRefused; _callManager.LocalInvitationAccepted += LocalInvitationAccepted; }
static void Main(string[] args) { string apiKey = "91d9ca5f94e7a83d7fcf9a6e0190191d"; string secret = "089415a5eeac8576"; var rtmAuthorizer = new RtmAuthorizer(apiKey, secret); string frob = rtmAuthorizer.GetFrob().First(); string authenticationUrl = rtmAuthorizer.GetAuthenticationUrl(frob); //Process.Start(authenticationUrl); //Console.WriteLine("Webページで認証してください。..."); //Console.ReadKey(); //var token = rtmAuthorizer.GetToken(frob).First(); //Console.WriteLine("Token:{0}", token.Token); RtmClient client = new RtmClient(apiKey, secret, "d0b897aaf58e530b52f49c15db9ff89c1679b6e9"); var lists = client.GetLists(); var list = lists.First(); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.ActivitySelection); _rtmClient = MainApplication.ChatManager.GetRtmClient(); InitUIAndData(); }
void OnApplicationQuit() { if (channel != null) { channel.Dispose(); channel = null; } if (rtmClient != null) { rtmClient.Dispose(); rtmClient = null; } }
private void InitChat() { rtmClient = _chatManager.GetRtmClient(); if (!_isPeerToPeerMode) { CreateAndJoinChannel(); } else { JoinPeer(); } }
private void InitChat() { InitCallbackAndListener(); _chatManager = MainApplication.ChatManager; rtmClient = _chatManager.GetRtmClient(); _chatManager.RegisterListener(_myRtmClientListener); if (!_isPeerToPeerMode) { CreateAndJoinChannel(); } PeerJoin(); }
public void Button_Logout() { if (rtmChannel != null) { rtmChannel.Dispose(); rtmChannel = null; } if (rtmClient != null) { rtmClient.Dispose(); rtmClient = null; } ChannelPanel.SetActive(false); RTMPanel.SetActive(true); }
private void Login() { clientEventHandler = new RtmClientEventHandler(); channelEventHandler = new RtmChannelEventHandler(); // RTM client callbacks clientEventHandler.OnLoginSuccess = OnClientLoginSuccessHandler; clientEventHandler.OnLoginFailure = OnClientLoginFailureHandler; // RTM channel-wide callbacks channelEventHandler.OnMessageReceived = OnChannelMessageReceivedHandler; channelEventHandler.OnSendMessageResult = OnSendMessageResultHandler; channelEventHandler.OnJoinSuccess = OnJoinSuccessHandler; rtmClient = new RtmClient(appID, clientEventHandler); rtmClient.Login("", userName); }
public static void UploadImage(Context context, RtmClient rtmClient, string file, ResultCallback resultCallback) { //var createResultCallback = new ResultCallback(); //createResultCallback.OnSuccessAction += (data) => //{ // Log.Debug(LogTag, $"UploadImage File: ${file}"); // var rtmImageMessage = data as RtmImageMessage; // Log.Debug(LogTag, $"UploadImage MediaId: ${rtmImageMessage.MediaId}"); // var width = rtmImageMessage.Width / 5; // var height = rtmImageMessage.Height / 5; // rtmImageMessage.SetThumbnail(PreloadImage(context, file, width, height)); // rtmImageMessage.ThumbnailWidth = width; // rtmImageMessage.ThumbnailHeight = height; // resultCallback.OnSuccess(rtmImageMessage); //}; //createResultCallback.OnFailureAction += (err) => resultCallback.OnFailureAction(err); //rtmClient.CreateImageMessageByUploading(file, new RtmRequestId(), createResultCallback); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.ActivityLogin); _userIdEditText = FindViewById <EditText>(Resource.Id.user_id); _loginBtn = FindViewById <TextView>(Resource.Id.button_login); _loginBtn.Click += OnClickLogin; MainApplication.ChatManager = new ChatManager(this); MainApplication.ChatManager.Init(); _rtmClient = MainApplication.ChatManager.GetRtmClient(); _callbackResult = new ResultCallback(); _callbackResult.OnSuccessAction += OnSuccessAction; _callbackResult.OnFailureAction += OnFailureAction; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.ActivityLogin); _userIdEditText = FindViewById <EditText>(Resource.Id.user_id); _loginBtn = FindViewById <TextView>(Resource.Id.button_login); _offlineCheck = FindViewById <CheckBox>(Resource.Id.offline_msg_check); _loginBtn.Click += OnClickLogin; MainApplication.ChatManager = new ChatManager(this); MainApplication.ChatManager.Init(); _offlineCheck.Checked = MainApplication.ChatManager.OfflineMessagesEnabled; _offlineCheck.CheckedChange += (s, e) => MainApplication.ChatManager.OfflineMessagesEnabled = _offlineCheck.Checked; _rtmClient = MainApplication.ChatManager.GetRtmClient(); _callbackResult = new ResultCallback(); _callbackResult.OnSuccessAction += OnSuccessAction; _callbackResult.OnFailureAction += OnFailureAction; }
protected Stopped(RtmClient fsm) : base(fsm) { }
// Use this for initialization void Start() { string version = RtmClient.GetSdkVersion(); rtmClient2 = new RtmClient(#YOUR_APPID, eventHandler2); rtmClient = new RtmClient(#YOUR_APPID, eventHandler); rtmClient.SetLogFile("./rtm_log.txt"); rtmClient.Login("", "100"); rtmClient2.Login("", "111"); rtmChannel1 = rtmClient.CreateChannel("222", channelEventHandler1); rtmChannel2 = rtmClient.CreateChannel("444", channelEventHandler2); // RtmChannelAttribute channelAttribute = rtmClient.CreateChannelAttribute(); // channelAttribute.SetKey("2323"); // channelAttribute.SetValue("5454"); // RtmChannelAttribute channelAttribute2 = rtmClient.CreateChannelAttribute(); // channelAttribute2.SetKey("2323233"); // channelAttribute2.SetValue("5454434"); // channelAttributes[0] = channelAttribute; // channelAttributes[1] = channelAttribute2; // ChannelAttributeOptions options = new ChannelAttributeOptions(); // options.enableNotificationToChannelMembers = false; // rtmClient.SetChannelAttributes("123", channelAttributes, options, 2838938); // channelAttribute = rtmClient.CreateChannelAttribute(); // channelAttribute.SetKey("287383"); // channelAttribute.SetValue("kjkkk"); // int m1 = rtmClient.GetChannelAttributes("2323", 232323); // Debug.Log("GetChannelAttributes = " + m1); // int m2 = rtmClient.ClearChannelAttributes("232k32", true, 232323); // Debug.Log("ClearChannelAttributes = " + m2); // int m3 = rtmClient.DeleteChannelAttributesByKeys("32323", new string[]{"23232", "439e"}, true, 2323); // Debug.Log("DeleteChannelAttributesByKeys m3 = " + m3); // int m4 = rtmClient.GetUserAttributesByKeys("23232", new string[]{"2323", "4343"}, 2323); // Debug.Log("GetUserAttributesByKeys m4 =" + m4); // int m5 = rtmClient.GetUserAttributes("2323", 323232); // Debug.Log("GetUsetAttribute = "+m5); // int m6 = rtmClient.ClearLocalUserAttributes(23232); // Debug.Log("ClearLocalUserAttribute = " + m6); // int m7 = rtmClient.DeleteLocalUserAttributesByKeys(new string[]{"232", "3232"}, 3232); // Debug.Log("DeleteLocalUserAttribute m7 = " + m7); rtmChannel1.Join(); rtmChannel2.Join(); channelEventHandler1.OnJoinSuccess = OnJoinSuccessHandler1; channelEventHandler2.OnJoinSuccess = OnJoinSuccessHandler2; channelEventHandler1.OnJoinFailure = OnJoinFailureHandler1; channelEventHandler2.OnJoinFailure = OnJoinFailureHandler2; channelEventHandler1.OnLeave = OnLeaveHandler; channelEventHandler2.OnLeave = OnLeaveHandler2; channelEventHandler1.OnMessageReceived = OnMessageReceivedFromChannelHandler; channelEventHandler2.OnMessageReceived = OnMessageReceivedFromChannelHandler2; channelEventHandler1.OnAttributesUpdated = OnAttributesUpdatedHandler; channelEventHandler2.OnAttributesUpdated = OnAttributesUpdatedHandler2; channelEventHandler1.OnMemberCountUpdated = OnMemberCountUpdatedHandler; channelEventHandler2.OnMemberCountUpdated = OnMemberCountUpdatedHandler2; channelEventHandler1.OnMemberJoined = OnMemberJoinedHandler1; channelEventHandler2.OnMemberJoined = OnMemberJoinedHandler2; channelEventHandler1.OnMemberLeft = OnMemberLeftHandler1; channelEventHandler2.OnMemberLeft = OnMemberLeftHandler2; channelEventHandler1.OnSendMessageResult = OnSendMessageResultHandler1; eventHandler.OnLoginSuccess = OnLoginSuccessHandler; eventHandler2.OnLoginSuccess = OnLoginSuccessHandler2; eventHandler.OnLogout = OnLogoutHandler; eventHandler2.OnLogout = OnLogoutHandler2; eventHandler.OnSendMessageResult = OnSendMessageResultHandler; eventHandler2.OnSendMessageResult = OnSendMessageResultHandler2; eventHandler.OnMessageReceivedFromPeer = OnMessageReceivedFromPeerHandler; eventHandler2.OnMessageReceivedFromPeer = OnMessageReceivedFromPeerHandler2; eventHandler.OnFileMediaUploadResult = OnFileMediaUploadResultHandler; eventHandler2.OnFileMediaUploadResult = OnFileMediaUploadResultHandler2; eventHandler.OnFileMessageReceivedFromPeer = OnFileMessageReceivedFromPeerHandler; eventHandler2.OnFileMessageReceivedFromPeer = OnFileMessageReceivedFromPeerHandler2; eventHandler.OnImageMessageReceivedFromPeer = OnImageMessageReceivedFromPeerHandler; eventHandler2.OnImageMessageReceivedFromPeer = OnImageMessageReceivedFromPeerHandler2; eventHandler.OnImageMediaUploadResult = OnImageMediaUploadResultHandler; eventHandler2.OnImageMediaUploadResult = OnImageMediaUploadResultHandler2; eventHandler.OnMediaUploadingProgress = OnMediaUploadingProgressHandler; eventHandler2.OnMediaUploadingProgress = OnMediaUploadingProgressHandler2; eventHandler.OnMediaDownloadingProgress = OnMediaDownloadingProgressHandler; eventHandler2.OnMediaDownloadingProgress = OnMediaDownloadingProgressHandler2; eventHandler.OnMediaDownloadToFileResult = OnMediaDownloadToFileResultHandler; eventHandler2.OnMediaDownloadToFileResult = OnMediaDownloadToFileResultHandler2; eventHandler.OnMediaDownloadToMemoryResult = OnMediaDownloadToMemoryResultHandler; eventHandler2.OnMediaDownloadToMemoryResult = OnMediaDownloadToMemoryResultHandler2; eventHandler.OnGetChannelAttributesResult = OnGetChannelAttributesResultHandler; eventHandler2.OnGetChannelAttributesResult = OnGetChannelAttributesResultHandler2; eventHandler.OnSetChannelAttributesResult = OnSetChannelAttributesResultHandler; eventHandler2.OnSetChannelAttributesResult = OnSetChannelAttributesResultHandler2; eventHandler.OnQueryPeersBySubscriptionOptionResult = OnQueryPeersBySubscriptionOptionResultHandler; eventHandler2.OnQueryPeersBySubscriptionOptionResult = OnQueryPeersBySubscriptionOptionResultHandler2; eventHandler.OnQueryPeersOnlineStatusResult = OnQueryPeersOnlineStatusResultHandler; eventHandler2.OnQueryPeersOnlineStatusResult = OnQueryPeersOnlineStatusResultHandler2; eventHandler.OnSubscriptionRequestResult = OnSubscriptionRequestResultHandler; eventHandler2.OnSubscriptionRequestResult = OnSubscriptionRequestResultHandler2; }
// Start is called before the first frame update void Start() { clientEventHandler = new RtmClientEventHandler(); channelEventHandler = new RtmChannelEventHandler(); callEventHandler = new RtmCallEventHandler(); rtmClient = new RtmClient(appId, clientEventHandler); #if UNITY_EDITOR rtmClient.SetLogFile("./rtm_log.txt"); #endif clientEventHandler.OnQueryPeersOnlineStatusResult = OnQueryPeersOnlineStatusResultHandler; clientEventHandler.OnLoginSuccess = OnClientLoginSuccessHandler; clientEventHandler.OnLoginFailure = OnClientLoginFailureHandler; clientEventHandler.OnMessageReceivedFromPeer = OnMessageReceivedFromPeerHandler; channelEventHandler.OnJoinSuccess = OnJoinSuccessHandler; channelEventHandler.OnJoinFailure = OnJoinFailureHandler; channelEventHandler.OnLeave = OnLeaveHandler; channelEventHandler.OnMessageReceived = OnChannelMessageReceivedHandler; // Optional, tracking members channelEventHandler.OnGetMembers = OnGetMembersHandler; channelEventHandler.OnMemberCountUpdated = OnMemberCountUpdatedHandler; channelEventHandler.OnMemberJoined = OnMemberJoinedHandler; channelEventHandler.OnMemberLeft = OnMemberLeftHandler; // image clientEventHandler.OnImageMessageReceivedFromPeer = OnImageMessageReceivedFromPeerHandler; clientEventHandler.OnImageMediaUploadResult = OnImageMediaUploadResultHandler; clientEventHandler.OnSendMessageResult = OnSendMessageResultHandler; clientEventHandler.OnMediaDownloadToFileResult = OnMediaDownloadToFileResultHandler; clientEventHandler.OnMediaDownloadToMemoryResult = OnMediaDownloadToMemoryResultHandler; // invite callEventHandler.OnLocalInvitationAccepted = OnLocalInvitationAcceptedHandler; callEventHandler.OnLocalInvitationCanceled = OnLocalInvitationCanceledHandler; callEventHandler.OnLocalInvitationFailure = OnLocalInvitationFailureHandler; callEventHandler.OnLocalInvitationReceivedByPeer = OnLocalInvitationReceivedByPeerHandler; callEventHandler.OnLocalInvitationRefused = OnLocalInvitationRefusedHandler; callEventHandler.OnRemoteInvitationAccepted = OnRemoteInvitationAcceptedHandler; callEventHandler.OnRemoteInvitationCanceled = OnRemoteInvitationCanceledHandler; callEventHandler.OnRemoteInvitationFailure = OnRemoteInvitationFailureHandler; callEventHandler.OnRemoteInvitationReceived = OnRemoteInvitationReceivedHandler; callEventHandler.OnRemoteInvitationRefused = OnRemoteInvitationRefusedHandler; callManager = rtmClient.GetRtmCallManager(callEventHandler); // state clientEventHandler.OnConnectionStateChanged = OnConnectionStateChangedHandler; bool initialized = ShowDisplayTexts(); if (initialized) { string ver = RtmClient.GetSdkVersion(); messageDisplay.AddTextToDisplay("RTM version " + ver + " initialized.", Message.MessageType.Info); } else { messageDisplay.AddTextToDisplay("RTM not initialized", Message.MessageType.Info); } }
public Uninitialized(RtmClient fsm) : base(fsm) { }