Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Sending stream event from publiher

...

Audio/video state notification: muted/unmuted

Stream audio state notifications are sending when Stream.muteAudio() and Stream.unmuteAudio() are called as follows:

Code Block
languagejs
themeRDark
    var muteAudio = function muteAudio() {
      if (mediaConnection) {
        mediaConnection.muteAudio();
        sendStreamEvent(STREAM_EVENT_TYPE.AUDIO_MUTED);
      }
    };
    ...
    var unmuteAudio = function unmuteAudio() {
      if (mediaConnection) {
        mediaConnection.unmuteAudio();
        sendStreamEvent(STREAM_EVENT_TYPE.AUDIO_UNMUTED);
      }
    };

Stream video state events notifications are sending when Stream.muteVideo() and Stream.unmuteVideo() are called:

Code Block
languagejs
themeRDark
    var muteVideo = function muteVideo() {
      if (mediaConnection) {
        mediaConnection.muteVideo();
        sendStreamEvent(STREAM_EVENT_TYPE.VIDEO_MUTED);
      }
    };
    ...
    var unmuteVideo = function unmuteVideo() {
      if (mediaConnection) {
        mediaConnection.unmuteVideo();
        sendStreamEvent(STREAM_EVENT_TYPE.VIDEO_UNMUTED);
      }
    };

Sending data to all the subscribers from publishing client

Since WCS build 5.2.942 and WebSDK build 2.0.168 it is possible to send any data in JSON format from publishing client to all the subscribers of stream published. To do this, Stream.sendData() method should be invoked, for example

Code Block
languagejs
themeRDark
stream.sendData({"number":33,"string":"hello",boolean:true});

Sending stream event from server

Since WCS build 5.2.944 it is possible to send an event with JSON data to all the stream subscribers from server using REST API. 

REST query should be HTTP/HTTPS POST query like this:

  • HTTP: http://test.flashphoner.com:8081/rest-api/stream/event/send
  • HTTPS: https://test.flashphoner.com:8444/rest-api/stream/event/send

Where:

  • test.flashphoner.com - WCS server address
  • 8081 - standard REST / HTTP port 
  • 8444 - standard HTTPS port
  • rest-api - mandatory part of the URL
  • /stream/event/send - REST method used

REST queries and response states

REST query

REST query body example

Responce states

Description

/stream/event/send

Code Block
languagejs
themeRDark
{
 "streamName":"test",
 "payload":{
  "number":33,
  "string":"hello",
  "boolean":true
 }
}

200 - OK

404 - Stream not found

500 - Internal server error (bad JSON)


Отправить данные всем подписчикам потока


Parameters

Name

Description

Example

streamNameИмя потокаtest

payload

Данные в формате JSON

{"number":33,"string":"hello","boolean":true}

If the stream published on server has no subscribers, then the query will return 200 OK, but the event will not be sent to anyone

Receiving stream event on subscribers side

...