Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

208
Views
El código Javascript para Socketio no funciona en C#

El problema es que, como dice el título, obtuve el paquete Nugget para Socket.io en C# , luego intenté mover el mismo código que tenía trabajando en Javascript , y no funciona en C#. Soy nuevo en WebSockets, por lo que agradecería cualquier ayuda.

Aquí está el código Javascript que funciona:

 const io = require('socket.io-client'); //function async function initSocket() { //define socket const socket = io( "wss://trade.csgoempire.com/trade", { transports: ["websocket"], path: "/s/", extraHeaders: { 'User-agent': `test API Bot` } } ); //connect event socket.on('connect', async() => { console.log(`Connected to websocket`); //log new items socket.on('new_item', (data) => console.log(`new_item`)); socket.on('deleted_item', (data) => console.log(`deleted_item`)); }); }; //run function initSocket();

Y aquí está el código C# que no lo hace:

 //define socket var SIO = new SocketIO("wss://trade.csgoempire.com/trade/", new SocketIOOptions() { EIO = 3, Transport = SocketIOClient.Transport.TransportProtocol.WebSocket, Path = "/s/", ExtraHeaders = new Dictionary<string, string> { { "User-agent", "Test API Bot" } } }); //connect event SIO.On("connect", async (connectData) => { Console.WriteLine("Connected to Websocket"); SIO.On("new_item", (data) => Console.WriteLine("new_item")); SIO.On("deleted_item", (data) => Console.WriteLine("deleted_item")); });

Mover todo el proyecto a JS es una opción, pero estoy realmente frustrado y no puedo entender qué estoy haciendo mal.

about 4 years ago · Santiago Gelvez
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!