TRtcHttpServer Connections.
2018-06-17 18:57:14来源:未知 阅读 ()
Author | TRtcHttpServer Connections. |
Steve Gill 02.09.2006 09:15:00
Registered user |
I would like to display the number of current connections in the server's main window. I have tried both the TotalConnectionCount and TotalServerConnectionCount methods in the Connect and Disconnect events. They seem to show the correct count when clients connect, but the counts seem to be one too many when the clients disconnect.
As each client connects the count goes up. However, the count seems do be one step behind on disconnects. When there is only 1 client connected it shows 2 connections. And when no clients are connected it shows 1 connection. procedure TfrmMain.HttpServerConnect(Sender: TRtcConnection); begin with Sender as TRtcConnection do begin edtConnections.IntValue := TotalConnectionCount; end; end; procedure TfrmMain.HttpServerDisconnect(Sender: TRtcConnection); begin with Sender as TRtcConnection do begin edtConnections.IntValue := TotalConnectionCount; end; end; Is there anything else I need to do? Regards, SteveG |
Danijel Tkalcec [RTC] 02.09.2006 14:11:31
Registered user |
TotalConnectionCount is increased before the first event is called and decreased after the last event was executed, which means that you should use "TotalConnectionCount-1" from the OnDisconnect/OnDisconnecting event.
Btw .. there's no need to cast Sender to TRtcConnection, since it already is TRtcConnection. You should only cast it to TRtcDataServer if you need more infromation. Also, if your Server is MultiThreaded, you need to Sync() your events before accessing the GUI: procedure TfrmMain.HttpServerConnect(Sender: TRtcConnection);
begin if not Sender.inMainThread then Sender.Sync(HttpServerConnect) else edtConnections.IntValue := Sender.TotalConnectionCount; end; procedure TfrmMain.HttpServerDisconnect(Sender: TRtcConnection); begin if not Sender.inMainThread then Sender.Sync(HttpServerDisconnect) else edtConnections.IntValue := Sender.TotalConnectionCount-1; end; Best Regards, Danijel Tkalcec |
Steve Gill 04.09.2006 01:49:14
Registered user |
Thanks Danijel.
> Btw .. there's no need to cast Sender to TRtcConnection, since > it already is TRtcConnection. You should only cast it to > TRtcDataServer if you need more infromation. Yeah, you're right. Force of habit I guess. > Also, if your Server is MultiThreaded, you need to Sync() your > events before accessing the GUI: Not multi-threaded but thanks for the code. Regards, SteveG PS How do you do the "quoting" in forum messages? |
Danijel Tkalcec [RTC] 04.09.2006 12:17:36
Registered user |
This Forum has a few BBCode functions implemented:
To open source code block, use [code]
To close source code block, use [ /code] - remove the space after [ To insert URL Link, use [url http://mydomain/mylink] To insert URL Link with your own text, use [url=http://mydomain/mylink]Mytext[/url] To insert Image, use [img http://mydomain.com/imagefile.gif] To insert Image with your own alt text, use [img=http://mydomain/myfile.gif]Alt text[/img] Best Regards, Danjel Tkalcec |
Steve Gill 05.09.2006 00:46:48
Registered user |
Nice. Thanks Danijel.
Regards, SteveG |
ISOFT, INC. 24.01.2007 16:26:38
Registered user |
The above code in Delphi looks like this in BCB
void __fastcall TForm1::RtcHttpServer1Connect(TRtcConnection *Sender) { if (Sender->inMainThread() == false) { Sender->Sync(&RtcHttpServer1Connect); } else { StatusBar1->SimpleText = "Total connections: " + AnsiString(Sender->TotalConnectionCount()); } } void __fastcall TForm1::RtcHttpServer1Disconnect(TRtcConnection *Sender) { if (Sender->inMainThread() == false) { Sender->Sync(&RtcHttpServer1Connect); } else { StatusBar1->SimpleText = "Total connections: " + AnsiString(Sender->TotalConnectionCount()-1); } } This is my first attempt at this - so I may not have done it exactly right. |
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
上一篇:用 RAD Studio 柏林版创建 IoT 应用程序
下一篇:Sessions
- 开源Launcher - Wox 出炉了 2018-06-17
- Login控件尝试 2018-06-17
- FormsAuthentication 登录兼容 IE11 保存cookie 2018-06-17
- Linux查看端口、进程情况及kill进程 2018-06-17
- SignalR代理对象异常:Uncaught TypeError: Cannot read pro 2018-06-17
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash