{"id":4844,"date":"2021-12-10T13:41:38","date_gmt":"2021-12-10T05:41:38","guid":{"rendered":"https:\/\/www.enablex.io\/developer\/?page_id=4844"},"modified":"2025-02-23T12:17:03","modified_gmt":"2025-02-23T04:17:03","slug":"room-connection","status":"publish","type":"page","link":"https:\/\/doc.smartflomeet.ttns.in\/developer\/video-api\/client-api\/cordova-toolkit\/room-connection\/","title":{"rendered":"Room Connection: Cordova\/Ionic SDK &#8211; Video API"},"content":{"rendered":"\n<h4>Table of Contents<\/h4>\n\n\n\n<ul><li><a href=\"#join-room\">Join a Room with Stream<\/a><\/li><li><a href=\"#init-view\" target=\"_blank\" rel=\"noreferrer noopener\">Initiate Local &amp; Remote View<\/a><\/li><li><a href=\"#disconnect-room\">Disconnect from a Room<\/a><\/li><\/ul>\n\n\n\n<a name=\"join-room\"><\/a>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2>Join a Room with Stream <\/h2>\n\n\n\n<p>Connecting and joining a Room is a complex chain of events. You will need to ensure success status of previous event to proceed to the next event. The following basic steps are required to join room successfully<\/p>\n\n\n\n<ul><li>Initiate Room &amp; Connect<\/li><li>If connected, initiate Stream. <\/li><li>Publish Stream<\/li><\/ul>\n\n\n\n<p><code>joinRoom()<\/code> method comes as a handy tool for developer. It handles all complexities of connecting and joining the room.<\/p>\n\n\n\n<p><strong>Method<\/strong>: <code>JoinRoom(token,publishStreamInfo,roomInfo,success,error)<\/code><\/p>\n\n\n\n<p><strong>Parameters<\/strong>: <\/p>\n\n\n\n<ul><li><code>@param {String} token -<\/code>it is encoded token string received from Enx application server.<\/li><li><code>@param {JSON} publishStreamInfo - <\/code>publishStreamInfo for local streams<\/li><li><code>@param {JSON} - roomInfo - <\/code>room info for joining room<\/li><li><code>@param {SuccessCallback} <\/code><\/li><li><code>@param {ErrorCallback} <\/code><\/li><\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">var streamOpt = {\naudio: true,\nvideo: true,\ndata: true,\naudioOnlyMode: false,\naudioMuted: false,\nvideoMuted: false,\nmaxVideoLayers: 1,\nname: \"Shashank\"\n};\nvar playerConfiguration = {\naudiomute: true,\nvideomute: true,\nbandwidth: true,\nscreenshot: true,\navatar: true,\niconHeight: 30,\niconWidth: 30,avatarHeight: 200,\navatarWidth: 200,\n};\nvar roomOpt = {\nactiveviews: \"list\",\nallow_reconnect: true,\nnumber_of_attempts: 3,\ntimeout_interval: 15,\nplayerConfiguration: playerConfiguration,\nforceTurn: false,\nchat_only: false,\n};\nwindow.EnxRtc.joinRoom(result.token, streamOpt,roomOpt, function\n(data) {\nconsole.log( JSON.stringify(data.data));\ninitLocalView(); \/\/ To init local View\ninitRemoteView(); \/\/ To init Remote View\n}, function (err) {\n}\n);<\/pre>\n\n\n\n<p><strong>Event Listeners: <\/strong><\/p>\n\n\n\n<ul><li><code>onRoomConnected<\/code> \u2013 When Client End Point is connected to the room successfully<\/li><li><code>onRoomDisConnected<\/code> \u2013 When Client End Point gets disconnected from the room<\/li><li><code>onRoomError<\/code> \u2013 When Client End Point\u2019s attempt to connect to room fails<\/li><li><code>onUserConnected<\/code> \u2013 Everyone is notified that a new user is connected to the Room<\/li><li><code>onUserDisConnected<\/code> \u2013 Everyone is notified that a user is disconnected from the Room<\/li><li><code>onConnectionLost<\/code> \u2013 When End Point loses network connection<\/li><li><code>onConnectionInterrupted<\/code> \u2013 When the connection is interrupted e.g Switch from WiFi to 4G and vice versa<\/li><li><code>onUserReconnectSuccess<\/code> \u2013 When End-Point successfully gets reconnected with the Portal<\/li><li> <code>onReconnect<\/code> \u2013 When End-Point tries to reconnect within the given time period.<\/li><li><code>onPublishedStream<\/code> \u2013 Publisher is notified that its Stream has been published into the Room<\/li><li><code>onUnPublishedStream<\/code> \u2013 Publisher is notified that its Stream is unpublished\/removed from the Room.<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">\/\/ Add Event Listeners\nwindow.EnxRtc.addEventListner(\"onRoomConnected\", function\n(data) {\nconsole.log( JSON.stringify(data.data));\n});\nwindow.EnxRtc.addEventListner(\"onRoomError\", function\n(data) {\nconsole.log( JSON.stringify(data.data));\ninitLocalView(); \/\/ To init local View\ninitRemoteView(); \/\/ To init Remote View\n});\nwindow.EnxRtc.addEventListner(\"onEventError\", function (data) {\nconsole.log(JSON.stringify(data.data));\n});window.EnxRtc.addEventListner(\"onUserConnected\", function (data) {\nconsole.log(JSON.stringify(data.data));\n});\nwindow.EnxRtc.addEventListner(\"onUserDisConnected\", function (data) {\nconsole.log( JSON.stringify(data.data));\n});<\/pre>\n\n\n\n<a name=\"init-view\"><\/a>\n\n\n\n<div style=\"height:40px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2>Initiate Local and Remote View<\/h2>\n\n\n\n<p>These methods are used to show local and remote streams. Users must initiate local and remote views in the success of the room-connected event.<\/p>\n\n\n\n<p><strong>Method:<\/strong><\/p>\n\n\n\n<p><code>initLocalView( localviewOptions, successCallback, errorCallback )<\/code><\/p>\n\n\n\n<p><strong>Parameters:<\/strong><\/p>\n\n\n\n<ul><li><code>@param {JSON} localviewOptions <\/code>&#8211; JSON object defining the display attributes as given below:<ul><li><code>height<\/code><\/li><li><code>width<\/code><\/li><li><code>margin_top<\/code><\/li><li><code>margin_left<\/code><\/li><li><code>margin_right<\/code><\/li><li><code>margin_bottom<\/code><\/li><li><code>position<\/code><\/li><\/ul><\/li><li><code>@param {SuccessCallback}<\/code><\/li><li><code>@param {ErrorCallback}<\/code><\/li><\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">\/\/ To Init Local View\nvar initLocalViewOptions = {\nheight: 130,\nwidth: 100,\nmargin_top: 50,\nmargin_left: 0,\nmargin_right: 15,\nmargin_bottom: 10,\nposition: \"top\"\n};\nwindow.EnxRtc.initLocalView(initLocalViewOptions,\nfunction\n(data) {\nconsole.log(JSON.stringify(data.data));\n}, function (err) {\nconsole.log('Uh oh\u2026 error' + JSON.stringify(err));});<\/pre>\n\n\n\n<p><strong>Method:<\/strong><\/p>\n\n\n\n<p><code>initRemoteView( remoteviewOptions, successCallback, errorCallback )<\/code><\/p>\n\n\n\n<p><strong>Parameters:<\/strong><\/p>\n\n\n\n<ul><li>@param {JSON} <code>remoteviewOptions<\/code> &#8211; JSON object defining the display attributes as given below:<ul><li><code>height<\/code><\/li><li><code>width<\/code><\/li><li><code>margin_top<\/code><\/li><li><code>margin_left<\/code><\/li><li><code>margin_right<\/code><\/li><li><code>margin_bottom<\/code><\/li><li><code>position<\/code><\/li><\/ul><\/li><li><code>@param {SuccessCallback}<\/code><\/li><li><code>@param {ErrorCallback}<\/code><\/li><\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">\/\/ To init Remote View\nvar initRemoteViewOptions = {\nheight: 600,\nwidth: 800,\nmargin_top: 100,\nmargin_left: 0,\nmargin_right: 15,\nmargin_bottom: 10,\nposition: \"center\"\n};\nwindow.EnxRtc.initRemoteView(initRemoteViewOptions, function\n(data) {\nconsole.log( JSON.stringify(data.data));\n}, function (err) {\nconsole.log(JSON.stringify(err));\n});<\/pre>\n\n\n\n<a name=\"disconnect-room\"><\/a>\n\n\n\n<div style=\"height:40px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2>Disconnect from a Room<\/h2>\n\n\n\n<p> A Client End Point can disconnect itself from the room to close its session. A disconnected End-Point will lose media and signaling socket immediately. <\/p>\n\n\n\n<p><strong>Method<\/strong>: <code>disconnect()<\/code> &#8211; Without any parameter<\/p>\n\n\n\n<p><strong>Event Listeners:<\/strong><\/p>\n\n\n\n<ul><li><code>onRoomDisconnected<\/code> \u2013 To the user who gets disconnected<\/li><li><code>onUserDisconnected<\/code> \u2013 To all other connected users<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">window.EnxRtc.disconnect();\n\/\/ Notified User who is disconnected .\nwindow.EnxRtc.addEventListner(\"onRoomDisConnected\",\nconsole.log(JSON.stringify(data.data));\n});\n\/\/ Other users in the room is notified.\nfunction (data)\n{window.EnxRtc.addEventListner(\"onUserDisConnected\",\nfunction (data)\n{\nconsole.log(JSON.stringify(data.data));\n});<\/pre>\n\n\n\n<div style=\"height:40px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<hr class=\"wp-block-separator is-style-wide\"\/>\n\n\n\n<div class=\"wp-block-columns\">\n<div class=\"wp-block-column\">\n<p>\u2190 <a href=\"..\/get-devices\/\">Get Media Devices<\/a><\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-column\">\n<p class=\"has-text-align-center\"><a href=\"..\/\">Index<\/a><\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-column\">\n<p class=\"has-text-align-right\"><a href=\"..\/switch-camera-mic-speaker\/\">Switch Camera, Mic, Speaker<\/a> \u2192<a href=\"\/developer\/how-to-use\/\"><\/a><\/p>\n<\/div>\n<\/div>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Table of Contents Join a Room with Stream Initiate Local &amp; Remote View Disconnect from a Room Join a Room with Stream Connecting and joining a Room is a complex chain of events. You will need to ensure success status of previous event to proceed to the next event. The following basic steps are required to join room successfully Initiate Room &amp; Connect If connected, initiate Stream. Publish Stream joinRoom()&hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"parent":3719,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"ub_ctt_via":""},"featured_image_src":null,"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false,"featured":false,"featured-large":false},"uagb_author_info":{"display_name":"vcxdevwpadmin","author_link":"https:\/\/doc.smartflomeet.ttns.in\/developer\/author\/vcxdevwpadmin\/"},"uagb_comment_info":0,"uagb_excerpt":"Table of Contents Join a Room with Stream Initiate Local &amp; Remote View Disconnect from a Room Join a Room with Stream Connecting and joining a Room is a complex chain of events. You will need to ensure success status of previous event to proceed to the next event. The following basic steps are required&hellip;","_links":{"self":[{"href":"https:\/\/doc.smartflomeet.ttns.in\/developer\/wp-json\/wp\/v2\/pages\/4844"}],"collection":[{"href":"https:\/\/doc.smartflomeet.ttns.in\/developer\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/doc.smartflomeet.ttns.in\/developer\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/doc.smartflomeet.ttns.in\/developer\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/doc.smartflomeet.ttns.in\/developer\/wp-json\/wp\/v2\/comments?post=4844"}],"version-history":[{"count":0,"href":"https:\/\/doc.smartflomeet.ttns.in\/developer\/wp-json\/wp\/v2\/pages\/4844\/revisions"}],"up":[{"embeddable":true,"href":"https:\/\/doc.smartflomeet.ttns.in\/developer\/wp-json\/wp\/v2\/pages\/3719"}],"wp:attachment":[{"href":"https:\/\/doc.smartflomeet.ttns.in\/developer\/wp-json\/wp\/v2\/media?parent=4844"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}