Add Message Received to ListBox
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'm trying to do a simple WebSocket Server in C# that will communicate with a Client in JavaScript, the code I am using is this:
using System;
using System.Windows.Forms;
using WebSocketSharp;
using WebSocketSharp.Server;
namespace MyProgram
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
var wssv = new WebSocketServer(8081);
wssv.WaitTime = TimeSpan.FromSeconds(3);
wssv.AddWebSocketService<NFP>("/");
wssv.Start();
}
}
public class NFP : WebSocketBehavior
{
protected override void OnMessage(MessageEventArgs e)
{
Console.WriteLine(e.Data);
Send("Received");
}
protected override void OnError(ErrorEventArgs e)
{
//Console.WriteLine(e.Exception);
}
protected override void OnClose(CloseEventArgs e)
{
//Console.WriteLine(e.Code);
}
}
}
Now I was wondering, how do I send the message received at OnMessage for the ListBox that is on Form1 already open?
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 code and NFP.OnMessage shown in the issue, then trace how the existing ListBox can receive e.Data from the WebSocket handler. Done means a message received by OnMessage is displayed in the already-open ListBox; verify the behavior with a JavaScript client sending a message.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, javascript
- Domain
- desktop, networking
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100