How to get access to Form objects in WebSocketBehavior class ?
Open
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 6.1k
- Forks
- 1.7k
- PR merge metrics
- No merged PRs in 30d
Description
I am using WebSocket server in a Form application. Like below:
public Form1()
{
InitializeComponent();
var wsServer = new WebSocketServer("ws://127.0.0.1");
wsServer.AddWebSocketService<WSB>("/rec");
wsServer.Start();
}
And the WSB:
public class WSB : WebSocketBehavior
{
protected override void OnOpen()
{
//base.OnOpen();
Console.WriteLine("[Agent INFO] Connected");
IPAddress clientIPAddress = Context.UserEndPoint.Address;
}
protected override void OnMessage(MessageEventArgs e)
{
Console.WriteLine("[Agent INFO] Message Received");
}
}
And I want to write clientIPAddress to Form1.label.Text. How can I get access to Form1 objects in WSB class' methods ?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Form1 constructor and the WSB WebSocketBehavior callbacks shown in the issue, then inspect how websocket-sharp invokes OnOpen and OnMessage. Determine the intended boundary between the WebSocketBehavior instance and the Form1 UI, including what completion means for updating label.Text safely.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- desktop, networking
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100