在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
//在form上拖放一个TsgcWebSocketClient 控件,控件采用ws协议,代码如下
procedure TForm16.Button1Click(Sender: TObject); begin try sgcWebSocketClient1.Host := 'echo.websocket.org'; sgcWebSocketClient1.Port := 80; sgcWebSocketClient1.Active := True; except on E: Exception do ShowMessage(e.Message); end; end; //procedure TForm16.Button2Click(Sender: TObject); //begin // sgcWebSocketServer1.Active := True; //end; procedure TForm16.Button3Click(Sender: TObject); begin sgcWebSocketClient1.WriteData('{"data":"12345","name": "skdjfklaj"}'); end; procedure TForm16.dealBackData(abc: string); begin if Pos('name', abc) > 0 then begin ShowMessage('有!'); end else begin ShowMessage('没有!'); end; end; procedure TForm16.sgcWebSocketClient1Message(Connection: TsgcWSConnection; const Text: string); begin Memo1.Lines.Add('Message Received From Server: ' + Text); dealBackData(Trim(Text)); end; |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论