Not receiving any sandbox notifications for eBay [closed] - ebay-api

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 years ago.
Improve this question
Using the below code, I am not seeing any sandbox notifications to our url or email for any event. I tried posting on eBay's dev forums but it seems to be a tumbleweed blowing through the planes over there.
I ran both sets of code to setup the notifications and then added a item, set feedback on it, marked it as sold. Nothing causes a notification.
This is the code for the application settings.
SetNotificationPreferencesCall apiCall = new SetNotificationPreferencesCall(usrApiContext);
var appPref = new ApplicationDeliveryPreferencesType();
appPref.ApplicationEnable = EnableCodeType.Enable;
appPref.ApplicationURL = "http://[ourdomain]/eBay/notification/receive";
appPref.AlertEnable = EnableCodeType.Enable;
appPref.AlertEmail = "mailto:jxxx#ourdomain.com";
appPref.PayloadVersion = "989";
appPref.DeviceType = DeviceTypeCodeType.Platform;
appPref.NotificationPayloadType = NotificationPayloadTypeCodeType.eBLSchemaSOAP;
apiCall.SetNotificationPreferences(appPref);
This is the code for the user.
var usrPref = new NotificationEnableTypeCollection();
#region Setup Notifications
usrPref.Add(new NotificationEnableType() { EventEnable = EnableCodeType.Enable, EventType = NotificationEventTypeCodeType.AskSellerQuestion });
usrPref.Add(new NotificationEnableType() { EventEnable = EnableCodeType.Enable, EventType = NotificationEventTypeCodeType.AuctionCheckoutComplete });
usrPref.Add(new NotificationEnableType() { EventEnable = EnableCodeType.Enable, EventType = NotificationEventTypeCodeType.BestOffer });
usrPref.Add(new NotificationEnableType() { EventEnable = EnableCodeType.Enable, EventType = NotificationEventTypeCodeType.BestOfferDeclined });
usrPref.Add(new NotificationEnableType() { EventEnable = EnableCodeType.Enable, EventType = NotificationEventTypeCodeType.BestOfferPlaced });
usrPref.Add(new NotificationEnableType() { EventEnable = EnableCodeType.Enable, EventType = NotificationEventTypeCodeType.BidItemEndingSoon });
usrPref.Add(new NotificationEnableType() { EventEnable = EnableCodeType.Enable, EventType = NotificationEventTypeCodeType.BidPlaced });
usrPref.Add(new NotificationEnableType() { EventEnable = EnableCodeType.Enable, EventType = NotificationEventTypeCodeType.BidReceived });
usrPref.Add(new NotificationEnableType() { EventEnable = EnableCodeType.Enable, EventType = NotificationEventTypeCodeType.BulkDataExchangeJobCompleted });
usrPref.Add(new NotificationEnableType() { EventEnable = EnableCodeType.Enable, EventType = NotificationEventTypeCodeType.BuyerCancelRequested });
usrPref.Add(new NotificationEnableType() { EventEnable = EnableCodeType.Enable, EventType = NotificationEventTypeCodeType.BuyerResponseDispute });
usrPref.Add(new NotificationEnableType() { EventEnable = EnableCodeType.Enable, EventType = NotificationEventTypeCodeType.Checkout });
usrPref.Add(new NotificationEnableType() { EventEnable = EnableCodeType.Enable, EventType = NotificationEventTypeCodeType.CheckoutBuyerRequestsTotal });
usrPref.Add(new NotificationEnableType() { EventEnable = EnableCodeType.Enable, EventType = NotificationEventTypeCodeType.CounterOfferReceived });
usrPref.Add(new NotificationEnableType() { EventEnable = EnableCodeType.Enable, EventType = NotificationEventTypeCodeType.EndOfAuction });
usrPref.Add(new NotificationEnableType() { EventEnable = EnableCodeType.Enable, EventType = NotificationEventTypeCodeType.Feedback });
usrPref.Add(new NotificationEnableType() { EventEnable = EnableCodeType.Enable, EventType = NotificationEventTypeCodeType.FeedbackForSeller });
usrPref.Add(new NotificationEnableType() { EventEnable = EnableCodeType.Enable, EventType = NotificationEventTypeCodeType.FeedbackLeft });
usrPref.Add(new NotificationEnableType() { EventEnable = EnableCodeType.Enable, EventType = NotificationEventTypeCodeType.FeedbackReceived });
usrPref.Add(new NotificationEnableType() { EventEnable = EnableCodeType.Enable, EventType = NotificationEventTypeCodeType.FeedbackStarChanged });
usrPref.Add(new NotificationEnableType() { EventEnable = EnableCodeType.Enable, EventType = NotificationEventTypeCodeType.FixedPriceTransaction });
usrPref.Add(new NotificationEnableType() { EventEnable = EnableCodeType.Enable, EventType = NotificationEventTypeCodeType.ItemAddedToBidGroup });
usrPref.Add(new NotificationEnableType() { EventEnable = EnableCodeType.Enable, EventType = NotificationEventTypeCodeType.ItemAddedToWatchList });
usrPref.Add(new NotificationEnableType() { EventEnable = EnableCodeType.Enable, EventType = NotificationEventTypeCodeType.ItemClosed });
usrPref.Add(new NotificationEnableType() { EventEnable = EnableCodeType.Enable, EventType = NotificationEventTypeCodeType.ItemExtended });
usrPref.Add(new NotificationEnableType() { EventEnable = EnableCodeType.Enable, EventType = NotificationEventTypeCodeType.ItemListed });
usrPref.Add(new NotificationEnableType() { EventEnable = EnableCodeType.Enable, EventType = NotificationEventTypeCodeType.ItemLost });
usrPref.Add(new NotificationEnableType() { EventEnable = EnableCodeType.Enable, EventType = NotificationEventTypeCodeType.ItemMarkedPaid });
usrPref.Add(new NotificationEnableType() { EventEnable = EnableCodeType.Enable, EventType = NotificationEventTypeCodeType.ItemMarkedShipped });
usrPref.Add(new NotificationEnableType() { EventEnable = EnableCodeType.Enable, EventType = NotificationEventTypeCodeType.ItemRevised });
usrPref.Add(new NotificationEnableType() { EventEnable = EnableCodeType.Enable, EventType = NotificationEventTypeCodeType.ItemRevisedAddCharity });
usrPref.Add(new NotificationEnableType() { EventEnable = EnableCodeType.Enable, EventType = NotificationEventTypeCodeType.ItemsCanceled });
usrPref.Add(new NotificationEnableType() { EventEnable = EnableCodeType.Enable, EventType = NotificationEventTypeCodeType.ItemSold });
usrPref.Add(new NotificationEnableType() { EventEnable = EnableCodeType.Enable, EventType = NotificationEventTypeCodeType.ItemSuspended });
usrPref.Add(new NotificationEnableType() { EventEnable = EnableCodeType.Enable, EventType = NotificationEventTypeCodeType.ItemUnsold });
usrPref.Add(new NotificationEnableType() { EventEnable = EnableCodeType.Enable, EventType = NotificationEventTypeCodeType.ItemWon });
usrPref.Add(new NotificationEnableType() { EventEnable = EnableCodeType.Enable, EventType = NotificationEventTypeCodeType.M2MMessageStatusChange });
usrPref.Add(new NotificationEnableType() { EventEnable = EnableCodeType.Enable, EventType = NotificationEventTypeCodeType.MyMessageseBayMessage });
usrPref.Add(new NotificationEnableType() { EventEnable = EnableCodeType.Enable, EventType = NotificationEventTypeCodeType.OutBid });
usrPref.Add(new NotificationEnableType() { EventEnable = EnableCodeType.Enable, EventType = NotificationEventTypeCodeType.PaymentReminder });
usrPref.Add(new NotificationEnableType() { EventEnable = EnableCodeType.Enable, EventType = NotificationEventTypeCodeType.PlaceOffer });
usrPref.Add(new NotificationEnableType() { EventEnable = EnableCodeType.Enable, EventType = NotificationEventTypeCodeType.ReadyForPayout });
usrPref.Add(new NotificationEnableType() { EventEnable = EnableCodeType.Enable, EventType = NotificationEventTypeCodeType.ReadyToShip });
usrPref.Add(new NotificationEnableType() { EventEnable = EnableCodeType.Enable, EventType = NotificationEventTypeCodeType.RefundFailure });
usrPref.Add(new NotificationEnableType() { EventEnable = EnableCodeType.Enable, EventType = NotificationEventTypeCodeType.RefundSuccess });
usrPref.Add(new NotificationEnableType() { EventEnable = EnableCodeType.Enable, EventType = NotificationEventTypeCodeType.RemoveFromWatchList });
usrPref.Add(new NotificationEnableType() { EventEnable = EnableCodeType.Enable, EventType = NotificationEventTypeCodeType.ReturnClosed });
usrPref.Add(new NotificationEnableType() { EventEnable = EnableCodeType.Enable, EventType = NotificationEventTypeCodeType.ReturnCreated });
usrPref.Add(new NotificationEnableType() { EventEnable = EnableCodeType.Enable, EventType = NotificationEventTypeCodeType.ReturnDelivered });
usrPref.Add(new NotificationEnableType() { EventEnable = EnableCodeType.Enable, EventType = NotificationEventTypeCodeType.ReturnEscalated });
usrPref.Add(new NotificationEnableType() { EventEnable = EnableCodeType.Enable, EventType = NotificationEventTypeCodeType.ReturnRefundOverdue });
usrPref.Add(new NotificationEnableType() { EventEnable = EnableCodeType.Enable, EventType = NotificationEventTypeCodeType.ReturnSellerInfoOverdue });
usrPref.Add(new NotificationEnableType() { EventEnable = EnableCodeType.Enable, EventType = NotificationEventTypeCodeType.ReturnShipped });
usrPref.Add(new NotificationEnableType() { EventEnable = EnableCodeType.Enable, EventType = NotificationEventTypeCodeType.ReturnWaitingForSellerInfo });
usrPref.Add(new NotificationEnableType() { EventEnable = EnableCodeType.Enable, EventType = NotificationEventTypeCodeType.SecondChanceOffer });
usrPref.Add(new NotificationEnableType() { EventEnable = EnableCodeType.Enable, EventType = NotificationEventTypeCodeType.SellerClosedDispute });
usrPref.Add(new NotificationEnableType() { EventEnable = EnableCodeType.Enable, EventType = NotificationEventTypeCodeType.SellerOpenedDispute });
usrPref.Add(new NotificationEnableType() { EventEnable = EnableCodeType.Enable, EventType = NotificationEventTypeCodeType.SellerRespondedToDispute });
usrPref.Add(new NotificationEnableType() { EventEnable = EnableCodeType.Enable, EventType = NotificationEventTypeCodeType.ShoppingCartItemEndingSoon });
usrPref.Add(new NotificationEnableType() { EventEnable = EnableCodeType.Enable, EventType = NotificationEventTypeCodeType.TokenRevocation });
usrPref.Add(new NotificationEnableType() { EventEnable = EnableCodeType.Enable, EventType = NotificationEventTypeCodeType.UnmatchedPaymentReceived });
usrPref.Add(new NotificationEnableType() { EventEnable = EnableCodeType.Enable, EventType = NotificationEventTypeCodeType.UserIDChanged });
usrPref.Add(new NotificationEnableType() { EventEnable = EnableCodeType.Enable, EventType = NotificationEventTypeCodeType.WatchedItemEndingSoon });
#endregion
apiCall.SetNotificationPreferences(usrPref);

Related

Custom header response when 401 /403 eror in .net 6/7

This is my code:
i am refernce this link:https://stackoverflow.com/a/71170460/7273263
services.AddAuthentication(options =>
{
options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
}).AddJwtBearer(o =>{
o.RequireHttpsMetadata = true;
o.SaveToken = true;
o.TokenValidationParameters = new TokenValidationParameters
{ ValidateIssuerSigningKey = true,
...other code
IssuerSigningKey = new SymmetricSecurityKey(key)
};
});
Newly Added code:
// Other configs...
o.Events = new JwtBearerEvents
{
OnChallenge = async context =>
{
// Call this to skip the default logic and avoid using the default response
var s = context.HttpContext.Response.StatusCode;
//***Here i am getting 200 error response***
context.HandleResponse();
var httpContext = context.HttpContext;
var statusCode = StatusCodes.Status401Unauthorized;
var routeData = httpContext.GetRouteData();
var actionContext = new ActionContext(httpContext, routeData, new ActionDescriptor());
var factory = httpContext.RequestServices.GetRequiredService<ProblemDetailsFactory>();
var problemDetails = factory.CreateProblemDetails(httpContext, statusCode);
var result = new ObjectResult(problemDetails) { StatusCode = statusCode };
await result.ExecuteResultAsync(actionContext);
}
};
The above code working fine .. but i need to response with 401 & 403 error How to dynamically add status code based on http code..if i hard coded 401 i am getting result as expected but it should work for 401 & 403 Please let me know is it possible or not
EDIT:
Controler method
[Authorize(Permissions.Master.Read)]
401 =>OnChallenge
OnChallenge = async context =>
{
context.HandleResponse();
context.Response.ContentType = "application/json";
context.Response.StatusCode = StatusCodes.Status401Unauthorized;
await context.Response.WriteAsync(JsonConvert.SerializeObject(new ErrorResponse()
{
Errors = new List<KeyValuePair<string, IEnumerable<string>>>
{
new KeyValuePair<string, IEnumerable<string>>(nameof(HttpStatusCode.Unauthorized),
new[] { "Your login has expired, please login again" })
}
}, new JsonSerializerSettings
{
ContractResolver = new CamelCasePropertyNamesContractResolver()
}));
}
403 => OnForbidden
OnForbidden = async context =>
{
context.Response.ContentType = "application/json";
context.Response.StatusCode = StatusCodes.Status403Forbidden;
await context.Response.WriteAsync(JsonConvert.SerializeObject(new ErrorResponse()
{
Errors = new List<KeyValuePair<string, IEnumerable<string>>>
{
new KeyValuePair<string, IEnumerable<string>>(nameof(HttpStatusCode.Forbidden),
new[] { "Access denied" })
}
}, new JsonSerializerSettings
{
ContractResolver = new CamelCasePropertyNamesContractResolver()
}));
},
full code
options.Events = new JwtBearerEvents
{
OnForbidden = async context =>
{
context.Response.ContentType = "application/json";
context.Response.StatusCode = StatusCodes.Status403Forbidden;
await context.Response.WriteAsync(JsonConvert.SerializeObject(new ErrorResponse()
{
Errors = new List<KeyValuePair<string, IEnumerable<string>>>
{
new KeyValuePair<string, IEnumerable<string>>(nameof(HttpStatusCode.Forbidden),
new[] { "Access denied" })
}
}, new JsonSerializerSettings
{
ContractResolver = new CamelCasePropertyNamesContractResolver()
}));
},
OnChallenge = async context =>
{
context.HandleResponse();
context.Response.ContentType = "application/json";
context.Response.StatusCode = StatusCodes.Status401Unauthorized;
await context.Response.WriteAsync(JsonConvert.SerializeObject(new ErrorResponse()
{
Errors = new List<KeyValuePair<string, IEnumerable<string>>>
{
new KeyValuePair<string, IEnumerable<string>>(nameof(HttpStatusCode.Unauthorized),
//new[] { context?.ErrorDescription ?? "Unauthenticated request" })
new[] { "Your login has expired, please login again" })
}
}, new JsonSerializerSettings
{
ContractResolver = new CamelCasePropertyNamesContractResolver()
}));
}
};

Getting error from react-native-sms-retriever

I am using react-native-sms-retriever packages to listen my sms from mobile. But it gives me an error after several minute passed.Even though I have added remove listener in useEffect.
let isApiSubscribed = true;
useEffect(async() => {
firstInput.current.focus();
if(isApiSubscribed){
_onSmsListenerPressed();
}
return () => {
isApiSubscribed = false;
SmsRetriever.removeSmsListener();
}
}, []);
const _onSmsListenerPressed = async () => {
try {
const registered = await SmsRetriever.startSmsRetriever();
if (registered) {
SmsRetriever.addSmsListener((event) => {
const message = event.message;
const otpCode = /(\d{4})/g.exec(message)[1];
const output = [];
const sNumber = otpCode.toString();
for (var i = 0, len = sNumber.length; i < len; i += 1) {
output.push(+sNumber.charAt(i));
}
const [currentPin1, currentPin2, currentPin3, currentPin4] = output;
setOtp({
...otp,
pin1: currentPin1,
pin2: currentPin2,
pin3: currentPin3,
pin4: currentPin4,
});
SmsRetriever.removeSmsListener();
isApiSubscribed = false;
Keyboard.dismiss();
});
}
} catch (error) {
console.log(JSON.stringify(error));
}
};
enter image description here

Failed to combine array of object react native

Im trying to join the data into the existing array of oject in state. in console.log(data) i get the data as expected but its not join together with this.state.listData.
"react-native": "0.61.5",
"#react-native-firebase/firestore": "^6.3.4",
retrieveMore = async () => {
const { navigation } = this.props;
const title2 = navigation.getParam('title2', null);
userEmail = firebase.auth().currentUser.email;
try {
const data = [];
await database.collection("All Recipes").orderBy("reviewCount", "desc").startAfter(this.state.lastVisible).limit(this.state.limit).get().then(doc => {
doc.forEach( async (doc) =>{
const {filter, id , name, image} = doc.data();
lastVisible = doc;
let recipeId = doc.data().id;
let test = await database.collection("All Recipes").doc(recipeId).collection("Reviews").onSnapshot(function(querySnapshot) {
let data2 = [];
querySnapshot.forEach(function(doc) {
const { Rating } = doc.data();
data2.push({
Rating: Rating,
});
});
const totalRating = data2.reduce((prev,next) => prev + next.Rating,0);
let averageRating = parseInt((Math.round(totalRating/data2.length * 100) / 100).toFixed(1));
let totalReview = Math.abs(data2.length) > 999 ? Math.sign(data2.length)*((Math.abs(data2.length)/1000).toFixed(1)) + 'k' : Math.sign(data2.length)*Math.abs(data2.length);
data.push({
filter: filter,
id:id,
name:name,
image:image,
averageRating: averageRating,
totalReview: totalReview,
});
});
});
console.log(data);
this.setState({
listData:[...this.state.listData, ...data],
lastVisible: lastVisible,
loading: false,
});
})
}
catch (error) {
console.log(error);
}
};
if i commented the the code like below,the data and the this.state.listData join perfectly but without averageRating and totalReview.
const data = [];
await database.collection("All Recipes").orderBy("reviewCount", "desc").startAfter(this.state.lastVisible).limit(this.state.limit).get().then(doc => {
doc.forEach( async (doc) =>{
const {filter, id , name, image} = doc.data();
lastVisible = doc;
let recipeId = doc.data().id;
// let test = await database.collection("All Recipes").doc(recipeId).collection("Reviews").onSnapshot(function(querySnapshot) {
// let data2 = [];
// querySnapshot.forEach(function(doc) {
// const { Rating } = doc.data();
// data2.push({
// Rating: Rating,
// });
// });
// const totalRating = data2.reduce((prev,next) => prev + next.Rating,0);
// let averageRating = parseInt((Math.round(totalRating/data2.length * 100) / 100).toFixed(1));
// let totalReview = Math.abs(data2.length) > 999 ? Math.sign(data2.length)*((Math.abs(data2.length)/1000).toFixed(1)) + 'k' : Math.sign(data2.length)*Math.abs(data2.length);
data.push({
filter: filter,
id:id,
name:name,
image:image,
// averageRating: averageRating,
// totalReview: totalReview,
});
});
// });
console.log(data);
this.setState({
listData:[...this.state.listData, ...data],
lastVisible: lastVisible,
loading: false,
});
})
this.setState(state=>({
listData:[...state.listData, ...data],
lastVisible: lastVisible,
loading: false,
}));
try this it may help you

Update array redux

I try to update a now playing state in Redux but everytime i call the update and it passes the check it get's added twice to the state.
result is that my filter when mapping (hide the first item) is not working due to the 2 additions.
Sample reducer:
import {
UPDATE_NOW_PLAYING,
UPDATE_ARTIST_AND_TITLE,
UPDATE_CURRENT_ARTIST
} from '../actions/actionTypes'
import { nowPlayingUrl, showNumberOfTracks, lastFmApiKey } from '../constants'
const currentState = {
playHistory: [],
currentArtist: '',
currentTitle: '',
currentShowName: '',
currentAlbumUrl: 'https://https://url.to.logo/app/app/logo-app.png'
}
const NowPlayingReducer = (state = currentState, action) => {
switch (action.type) {
case UPDATE_ARTIST_AND_TITLE: {
if (state.currentArtist !== action.array[0].artist) {
return {
...state,
playHistory: state.playHistory.concat(action.array[0]),
currentArtist: action.array[0].artist,
currentTitle: action.array[0].title,
currentShowName: action.array[0].showName,
currentAlbumUrl: action.array[0].albumUrl
}
}
return state
}
case UPDATE_NOW_PLAYING: {
return {
...state,
playHistory: action.payload,
currentArtist: action.payload[0].artist,
currentTitle: action.payload[0].title,
currentShowName: action.payload[0].showName,
currentAlbumUrl: action.payload[0].albumUrl
}
}
default: return state
}
}
export default NowPlayingReducer
So it works, but the only part is the second addition somehow :(
//Edit:
componentWillMount() {
this.getNowPlaying()
}
componentDidMount() {
setInterval(async () => {
await this.updateCurrentInformation()
}, 10000);
}
updateCurrentInformation = async () => {
try {
let currentPlayingResponse = await fetch(nowPlayingUrl + 1 )
let currentPlayingJson = await currentPlayingResponse.json()
let newArray = []
Promise.all(
currentPlayingJson.nowplaying.map(async (album) => {
const albumObj = await this.getAlbumInformation(album);
newArray.push(albumObj);
this.props.updateArtistAndTitle(newArray)
})
);
} catch(error) { console.log(error)};
}
togglePlayerType() {
}
getNowPlaying = async () => {
try {
let nowPlayingResponse = await fetch(nowPlayingUrl + showNumberOfTracks);
let nowPlayingJson = await nowPlayingResponse.json();
let newArray = [];
Promise.all(
nowPlayingJson.nowplaying.map(async (album) => {
const albumObj = await this.getAlbumInformation(album);
newArray.push(albumObj);
this.props.updateNowPlaying(newArray);
})
);
} catch (err) {
console.log(err);
}
}
getAlbumInformation = async (album) => {
return new Promise(async (resolve, reject) => {
let id = JSON.stringify(album.id).replace(/"/g, '');
let title = JSON.stringify(album.title)
.replace(/"/g, '')
.replace(/([&][^&; ]+[;])/g, '');
let artist = JSON.stringify(album.artist)
.replace(/"/g, '')
.replace(/([&][^&; ]+[;])/g, '');
let dateTime = JSON.stringify(album.datetime).replace(/"/g, '');
let showName = JSON.stringify(album.showName).replace(/"/g, '');
let albumUrl = 'https://url.to.logo/app/logo-app.png';
let obj = { id, title, artist, dateTime, showName, albumUrl };
try {
let albumResponse = await fetch(
`https://ws.audioscrobbler.com/2.0/?method=track.getInfo&format=json&api_key=${lastFmApiKey}&artist=${artist}&track=${title}`
);
let albumJson = await albumResponse.json();
if (albumJson) {
url = albumJson.track.album.image[3]['#text'];
if (url > '') {
obj.albumUrl = albumJson.track.album.image[3]['#text'];
} else {
obj.albumUrl = 'https://url.to.logo/app/logo-app.png';
}
}
resolve(obj);
} catch (err) {
resolve(obj);
}
});
}

Uncaught (in promise) DOMException: Error processing ICE candidate WebRTC RTCIceCandidate

turns out this error please help where the problem
** Uncaught (in promise) DOMException: Error processing ICE candidate **
here is the source code of the call
ConOut.getStartScreenSharing => ConIn.socket.on('OnMessage') => onOffer()
there the getStartScreenSharing function is called
did everything according to the example
using Chrome 68.0.3440.106 browser
import Vue from "vue";
export default class ConOut {
constructor() {
let t = this;
t.pc = new RTCPeerConnection();
this.socket = Vue.prototype.$signalR;
this.socket.on('OnMessage', (chName, message) => {
var desc = JSON.parse(message);
if (desc.type === 'candidate') {
t.pc.addIceCandidate(new RTCIceCandidate({
sdpMLineIndex: desc.label,
candidate: desc.candidate
}))
}
if (desc.type == 'answer') {
t.pc.setRemoteDescription(desc);
}
});
this.socket.start().then(function () {});
}
send = function (message) {
this.socket.invoke("SendOtherV2", this.channelName, JSON.stringify(message));
}
getStartScreenSharing() {
let t = this;
navigator.getUserMedia({
audio: false,
video: true
}, function (stream) {
t.pc.addStream(stream);
t.pc.createOffer().then(function (ff) {
t.pc.setLocalDescription(ff);
t.send({
type: "offer",
offer: ff
});
});
t.pc.onicecandidate = function (event) {
if (event.candidate) {
t.send({
type: 'candidate',
label: event.candidate.sdpMLineIndex,
id: event.candidate.sdpMid,
candidate: event.candidate.candidate
})
};
t.pc.onaddstream = function (s) {
t.CreateVideoTag(s)
}
};
})
}
};
here we wait for the Offer and answer
import Vue from "vue";
export default class ConIn {
constructor() {
let t = this;
t.pc = new RTCPeerConnection();
this.socket = Vue.prototype.$signalR;
this.socket.on('OnMessage', (chName, message) => {
var desc = JSON.parse(message);
if (desc.type === 'candidate') {
console.log(desc)
t.pc.addIceCandidate(new RTCIceCandidate({
sdpMLineIndex: desc.label,
candidate: desc.candidate
}))
} else {
t.onOffer(desc.offer)
}
});
this.socket.start().then(function () {});
}
send = function (message) {
this.socket.invoke("SendOtherV2", this.channelName, JSON.stringify(message));
}
onOffer(offer) {
let t = this;
navigator.getUserMedia({
audio: false,
video: true
}, function (stream) {
t.pc.addStream(stream);
t.pc.setRemoteDescription(new RTCSessionDescription(offer), function () {
t.pc.createAnswer(function (answer) {
t.pc.setLocalDescription(answer);
t.send(answer)
});
});
t.pc.onicecandidate = function (event) {
if (event.candidate) {
t.send({
type: 'candidate',
label: event.candidate.sdpMLineIndex,
id: event.candidate.sdpMid,
candidate: event.candidate.candidate
})
}
t.pc.onaddstream = function (s) {
t.CreateVideoTag(s)
}
};
})
}
};
here is the code that works without errors
ConOut.js
import Vue from "vue";
export default class ConOut {
constructor() {
let t = this;
t.pc = new RTCPeerConnection();
t.pc.onicecandidate = function (event) {
if (event.candidate) {
t.send({
type: 'candidate',
candidate: event.candidate
})
};
};
t.pc.onaddstream = function (s) {
console.log('onaddstream')
t.createVideoTag(s)
}
this.socket = Vue.prototype.$signalR;
this.socket.on('OnMessage', (chName, message) => {
var desc = JSON.parse(message);
if (desc.type === 'candidate') {
t.pc.addIceCandidate(new RTCIceCandidate(desc.candidate))
}
if (desc.type == 'answer') {
t.pc.setRemoteDescription(new RTCSessionDescription(desc), function () {
console.log('Setting remote description by answer');
}, function (e) {
console.error(e);
});
}
});
this.socket.start().then(function () {
console.info('SignalR connection is opened.');
});
}
send = function (message) {
this.socket.invoke("SendOtherV2", this.channelName, JSON.stringify(message));
}
getStartScreenSharing() {
let t = this;
navigator.getUserMedia({
audio: false,
video: true
}, function (stream) {
t.pc.addStream(stream);
t.pc.createOffer().then(function (ff) {
t.pc.setLocalDescription(ff);
t.send({
type: "offer",
offer: ff
});
});
})
}
createVideoTag = function (s, isRemote = false) {
let videoContener = document.getElementById('videoContener');
let x = document.createElement("VIDEO");
x.setAttribute("width", "320");
x.setAttribute("height", "240");
x.srcObject = s.stream;
x.controls = true
x.playsinline = true
x.autoplay = true
videoContener.appendChild(x);
return x;
}
};
ConIn.js
import Vue from "vue";
export default class ConIn {
constructor() {
let t = this;
t.ic = [];
t.isSetRD = false
t.pc = new RTCPeerConnection();
t.pc.onicecandidate = function (event) {
if (event.candidate) {
t.send({
type: 'candidate',
candidate: event.candidate
})
};
};
t.pc.onaddstream = function (s) {
console.log('onaddstream')
t.createVideoTag(s)
}
this.socket = Vue.prototype.$signalR;
this.socket.on('OnMessage', (chName, message) => {
var desc = JSON.parse(message);
console.log(desc)
if (desc.type === 'candidate') {
setTimeout(function () {
t.pc.addIceCandidate(new RTCIceCandidate(desc.candidate))
}, 5000);
} else {
t.onOffer(desc.offer)
}
});
this.socket.start().then(function () {
if (t.enableLogs) {
console.info('SignalR connection is opened.');
}
});
}
send = function (message) {
this.socket.invoke("SendOtherV2", this.channelName, JSON.stringify(message));
}
onOffer(offer) {
let t = this;
navigator.getUserMedia({
audio: false,
video: true
}, function (stream) {
t.pc.addStream(stream);
t.pc.setRemoteDescription(new RTCSessionDescription(offer))
.then(() => t.pc.createAnswer())
.then(answer => {
t.pc.setLocalDescription(answer)
t.send(answer)
})
.catch(e => console.error(e));
})
}
createVideoTag = function (s, isRemote = false) {
let videoContener = document.getElementById('videoContener');
let x = document.createElement("VIDEO");
x.setAttribute("width", "320");
x.setAttribute("height", "240");
x.srcObject = s.stream;
x.controls = true
x.playsinline = true
x.autoplay = true
videoContener.appendChild(x);
return x;
}
};