problem to use websocketsharp in lower layer
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 20/100
- Issue type
- Refactor
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- csharp
- Domain
- desktop, networking
Research direction
The issue only shows websocket usage in Form1 and its button and load handlers; start by tracing those handlers and the WebSocket event callbacks. Determine whether the connection and message handling can be separated from the Windows Forms controls, with the data-layer class exposing a usable connection, send, receive, and close workflow.
Written by the indexing model from the issue text.
Description
Hi guys
i am programing on windows form project
can any body help me to use websocketsharp in lower layer (Data layer) ??
this code works fine to me, but i dont know how must be use in data layer as a class
` private WebSocket _webSocket;
const string Uri = "wss://api.com/ws";
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
try
{
_webSocket = new WebSocket(Uri);
_webSocket.OnOpen += (ss, ee) =>
listBox1.Items.Add(string.Format("Connected to {0} successfully ", Uri));
_webSocket.OnError += (ss, ee) =>
listBox1.Items.Add(" Error: " + ee.Message);
_webSocket.OnMessage += (ss, ee) =>
this.Invoke((MethodInvoker)delegate
{
richTextBox1.Text = ee.Data.ToString();
});
_webSocket.OnClose += (ss, ee) =>
listBox1.Items.Add(string.Format("Disconnected with {0}", Uri));
}
catch (Exception exception)
{
MessageBox.Show(exception.Message);
throw;
}
}
private void btnConnect_Click(object sender, EventArgs e)
{
_webSocket.Connect();
}
private void btnDisconnect_Click(object sender, EventArgs e)
{
_webSocket.Close();
}
private void btnSend_Click(object sender, EventArgs e)
{
var content = inputBox.Text;
if (!string.IsNullOrEmpty(content))
_webSocket.Send(content);
}`
- Dominant language
- C#
- Stars
- 6.1k
- Forks
- 1.7k
- PR merge metrics
- No merged PRs in 30d
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.
More from sta/websocket-sharp
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
sta/websocket-sharp#201 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 45/100
sta/websocket-sharp#762 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 25/100
sta/websocket-sharp#761 ·
-
Bad handling of sending stream makes lib not RFC compatible and KeepClean useless in some cases. Open
Difficulty 4/5 3-5 days Newbie friendliness 42/100
sta/websocket-sharp#760 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
sta/websocket-sharp#759 ·
All issues in sta/websocket-sharp
Similar issues
-
bug documentation frontend
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
azurenoops/spin_agent#975 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
-
:watch: Not Triaged 11.0 fundamentals/subsvc
Difficulty 2/5 1-3 hours Newbie friendliness 92/100
dotnet/AspNetCore.Docs#37699 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
SubtitleEdit/subtitleedit#15108 · 1 comment ·
-
area/docs-content Bug pulumi/docs
Difficulty 1/5 1-3 hours Newbie friendliness 94/100