sta / sta/websocket-sharp

How to work with socketio server and send "emit" request

Open
#328 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
6.1k
Forks
1.7k
PR merge metrics
No merged PRs in 30d

Description

Hey, i can connect to my socketio server, but how can i send a requst with params?
My socketio listen event

socket.on('init', ( data ) => {
    console.log('init', data);
});

on client side i tryed to do this

 _socket.OnMessage += (sender, e) =>
{
    Console.WriteLine("message: {0} {1}", e.IsBinary, e.Data);
    _socket.Send(MakePacket("init", new Init
        {
            key = "1",
            room = "eq",
            type = "s"
        }.ToJson())
    );
};
private string MakePacket(string e, string data)
{
    return new[] {e, data}.ToJson();
}

so i send json to server ["init", {"type":"s","key":"1","room":"eq"}]
But server wont react at this packet.
What i do wrong? Thank you for any reply.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No repository file or test is named. Start with the websocket-sharp usage around _socket.OnMessage, _socket.Send, and MakePacket, then compare the emitted payload with the server's expected protocol. Done means documenting the supported packet format and a verified example.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, javascript
Domain
api, networking
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.