RTCMultiConnection-SignalR icon indicating copy to clipboard operation
RTCMultiConnection-SignalR copied to clipboard

Does not work with latest RTCMultiConnection

Open leo-mck opened this issue 6 years ago • 7 comments

I was not able to run this with the latest version of RTCMultiConnection.js :( If I use the version from this repo, it works fine

leo-mck avatar Feb 08 '19 20:02 leo-mck

I can some help.

  1. function connection.socket.emit should some fix with next code:
connection.socket.emit = function (eventName, data, callback) {
		if (eventName === 'changed-uuid') return;
		if (data.message && data.message.shiftedModerationControl) return;

		connection.socket.send({
			eventName: eventName,
			data: data
		});

        if (callback) {
            callback = callback || function () { };

            if (eventName === 'open-room' || eventName === 'join-room') {
                callback(true, null); 
            }
            else {
                callback();
            }
		}
    };
  1. Then should insert code function onMessagesCallback(message) from RTCMultiConnection.js function onMessageEvent(message) and remove string updateExtraBackup(message.sender, message.extra);

For me it works but it's no clean fix. I also wait for answer from developer

alexsandr1992 avatar Apr 01 '20 06:04 alexsandr1992

I can some help.

  1. function connection.socket.emit should some fix with next code:
connection.socket.emit = function (eventName, data, callback) {
		if (eventName === 'changed-uuid') return;
		if (data.message && data.message.shiftedModerationControl) return;

		connection.socket.send({
			eventName: eventName,
			data: data
		});

        if (callback) {
            callback = callback || function () { };

            if (eventName === 'open-room' || eventName === 'join-room') {
                callback(true, null); 
            }
            else {
                callback();
            }
		}
    };
  1. Then should insert code function onMessagesCallback(message) from RTCMultiConnection.js function onMessageEvent(message) and remove string updateExtraBackup(message.sender, message.extra);

For me it works but it's no clean fix. I also wait for answer from developer

Can you share RTCMultiConnection.js

VetonAbdiu avatar Jun 22 '20 19:06 VetonAbdiu

@alexsandr1992 what did you do regarding the function onMessagesCallback(message) and function onMessageEvent(message), that was not clear in your comment? would you please elaborate more? Thanks.

ghost avatar Aug 20 '20 14:08 ghost

@alexsandr1992 what did you do regarding the function onMessagesCallback(message) and function onMessageEvent(message), that was not clear in your comment? would you please elaborate more? Thanks.

Hi, Thats my changes of file SignalRConnection.js. Sorry, but I use object instead functions, so maybe changes see some hard

onMessagesCallback: function (message) {
        var connection = SignalRConnection.connection;
        var mPeer = connection.multiPeersHandler;

        if (message.remoteUserId !== connection.userid && !message.message.newParticipationRequest) return;

        if (connection.peers[message.sender] && connection.peers[message.sender].extra !== message.message.extra) {
            connection.peers[message.sender].extra = message.extra;
            connection.onExtraDataUpdated({
                userid: message.sender,
                extra: message.extra
            });
        }

        if (message.message.streamSyncNeeded && connection.peers[message.sender]) {
            var stream = connection.streamEvents[message.message.streamid];
            if (!stream || !stream.stream) {
                return;
            }

            var action = message.message.action;

            if (action === 'ended' || action === 'inactive' || action === 'stream-removed') {
                if (connection.peersBackup[stream.userid]) {
                    stream.extra = connection.peersBackup[stream.userid].extra;
                }
                connection.onstreamended(stream);
                return;
            }

            var type = message.message.type !== 'both' ? message.message.type : null;

            if (typeof stream.stream[action] === 'function') {
                stream.stream[action](type);
            }
            return;
        }

        if (message.message === 'dropPeerConnection') {
            connection.deletePeer(message.sender);
            return;
        }

        if (message.message.allParticipants) {
            if (message.message.allParticipants.indexOf(message.sender) === -1) {
                message.message.allParticipants.push(message.sender);
            }

            message.message.allParticipants.forEach(function (participant) {
                mPeer[!connection.peers[participant] ? 'createNewPeer' : 'renegotiatePeer'](participant, {
                    localPeerSdpConstraints: {
                        OfferToReceiveAudio: connection.sdpConstraints.mandatory.OfferToReceiveAudio,
                        OfferToReceiveVideo: connection.sdpConstraints.mandatory.OfferToReceiveVideo
                    },
                    remotePeerSdpConstraints: {
                        OfferToReceiveAudio: connection.session.oneway ? !!connection.session.audio : connection.sdpConstraints.mandatory.OfferToReceiveAudio,
                        OfferToReceiveVideo: connection.session.oneway ? !!connection.session.video || !!connection.session.screen : connection.sdpConstraints.mandatory.OfferToReceiveVideo
                    },
                    isOneWay: !!connection.session.oneway || connection.direction === 'one-way',
                    isDataOnly: isData(connection.session)
                });
            });
            return;
        }

        if (message.message.newParticipant) {
            if (message.message.newParticipant === connection.userid) return;
            if (connection.peers[message.message.newParticipant]) return;

            mPeer.createNewPeer(message.message.newParticipant, message.message.userPreferences || {
                localPeerSdpConstraints: {
                    OfferToReceiveAudio: connection.sdpConstraints.mandatory.OfferToReceiveAudio,
                    OfferToReceiveVideo: connection.sdpConstraints.mandatory.OfferToReceiveVideo
                },
                remotePeerSdpConstraints: {
                    OfferToReceiveAudio: connection.session.oneway ? !!connection.session.audio : connection.sdpConstraints.mandatory.OfferToReceiveAudio,
                    OfferToReceiveVideo: connection.session.oneway ? !!connection.session.video || !!connection.session.screen : connection.sdpConstraints.mandatory.OfferToReceiveVideo
                },
                isOneWay: !!connection.session.oneway || connection.direction === 'one-way',
                isDataOnly: isData(connection.session)
            });
            return;
        }

        if (message.message.readyForOffer) {
            if (connection.attachStreams.length) {
                connection.waitingForLocalMedia = false;
            }

            if (connection.waitingForLocalMedia) {
                // if someone is waiting to join you
                // make sure that we've local media before making a handshake
                setTimeout(function () {
                    onMessageEvent(message);
                }, 1);
                return;
            }
        }

        if (message.message.newParticipationRequest && message.sender !== connection.userid) {
            if (connection.peers[message.sender]) {
                connection.deletePeer(message.sender);
            }

            var userPreferences = {
                extra: message.extra || {},
                localPeerSdpConstraints: message.message.remotePeerSdpConstraints || {
                    OfferToReceiveAudio: connection.sdpConstraints.mandatory.OfferToReceiveAudio,
                    OfferToReceiveVideo: connection.sdpConstraints.mandatory.OfferToReceiveVideo
                },
                remotePeerSdpConstraints: message.message.localPeerSdpConstraints || {
                    OfferToReceiveAudio: connection.session.oneway ? !!connection.session.audio : connection.sdpConstraints.mandatory.OfferToReceiveAudio,
                    OfferToReceiveVideo: connection.session.oneway ? !!connection.session.video || !!connection.session.screen : connection.sdpConstraints.mandatory.OfferToReceiveVideo
                },
                isOneWay: typeof message.message.isOneWay !== 'undefined' ? message.message.isOneWay : !!connection.session.oneway || connection.direction === 'one-way',
                isDataOnly: typeof message.message.isDataOnly !== 'undefined' ? message.message.isDataOnly : isData(connection.session),
                dontGetRemoteStream: typeof message.message.isOneWay !== 'undefined' ? message.message.isOneWay : !!connection.session.oneway || connection.direction === 'one-way',
                dontAttachLocalStream: !!message.message.dontGetRemoteStream,
                connectionDescription: message,
                successCallback: function () { }
            };

            connection.onNewParticipant(message.sender, userPreferences);
            return;
        }

        if (message.message.changedUUID) {
            if (connection.peers[message.message.oldUUID]) {
                connection.peers[message.message.newUUID] = connection.peers[message.message.oldUUID];
                delete connection.peers[message.message.oldUUID];
            }
        }

        if (message.message.userLeft) {
            mPeer.onUserLeft(message.sender);

            if (message.message.autoCloseEntireSession) {
                connection.leave();
            }

            return;
        }

        mPeer.addNegotiatedMessage(message.message, message.sender);
    }```

alexsandr1992 avatar Aug 20 '20 14:08 alexsandr1992

@alexsandr1992 Are you using RTCMultiConnection.js version v3.6.9? if yes would you please share it with us? Thanks.

ghost avatar Aug 20 '20 14:08 ghost

@alexsandr1992 Are you using RTCMultiConnection.js version v3.6.9? if yes would you please share it with us? Thanks.

yes, I use RTCMultiConnection.js version v3.6.9 and code in this file in my project is same that in repository.

alexsandr1992 avatar Aug 20 '20 15:08 alexsandr1992

IT'S Working NOW!!!!! Thank you soooo much @alexsandr1992, I replaced my onMessagesCallback(message) with the one that you provided above, I made only one change, I removed var connection = SignalRConnection.connection; cause I have connection as global var.

Also, I replaced connection.socket.emit with the one you mentioned earlier above.

What a great day!!

ghost avatar Aug 20 '20 16:08 ghost