• 软件测试技术
  • 软件测试博客
  • 软件测试视频
  • 开源软件测试技术
  • 软件测试论坛
  • 软件测试沙龙
  • 软件测试资料下载
  • 软件测试杂志
  • 软件测试人才招聘
    暂时没有公告

字号: | 推荐给好友 上一篇 | 下一篇

用Winsock建立一个聊天室

发布: 2007-6-21 21:57 | 作者:   | 来源:   | 查看: 31次 | 进入软件测试论坛讨论

领测软件测试网

   
  Creating a Chat Session

Now that you注释:ve established two-way communication, the world注释:s your oyster. You could do absolutely diddly anything.

One thing you might want to have a look at is chat sessions. Now if you put a little imagination into it, you can turn the instant messaging functionality you have right now into a chat session, no problemo.

Think about it: every time data arrives via the DataArrival event, you could add it to a colourful Text Box. And each time your user taps something in to send, this could also be added to the box. And there you have it ?your chat session!

If you fancy playing around with this, try grabbing my download from the previous page ?and making a few teensy-weensy alterations:

Extend Form1 a little
Add a Text Box to the newly expanded area
Changed the Text Box properties as so:
Name - txtChatLog

Font - Arial, Bold, 9

ForeColor - Dark Red

Locked - True

This Text Box will be your chat log. Next, we注释:re going to add code that inserts text into the chat box every time a message is either sent or received.

Insert the following code behind your Form:
Public Sub AddToChatBox(Speaker As String, Sentence As String)

    txtChatLog.Text = txtChatLog.Text & _
        (Speaker & ": " & vbTab & "" & Sentence) & _
        vbCrLf

End SubAdd the following code to the end of the Winsock DataArrival event:
AddToChatBox "Remote", strIncomingAdd the following code after the SendData methods under the Command Button:
AddToChatBox "You", strOutgoingMessage.TextAnd that注释:s it! Every time a message is sent back and forth, it gets added to the log ?creating a virtual chat session. Corr blimey ?sneaky or what?

Top Tip: If you注释:re wanting to knock-up a multi-user chat room, check out this site: http://www.freevbcode.com/ShowCode.Asp?ID=137, which demonstrates using multiple Winsock connections. You can even create your own mini ICQ with this good-looking download http://www.planetsourcecode.com/xq/ASP/txtCodeId.6520/lngWId.1/qx/vb/scripts/ShowCode.htm from Evan Sims.

文章来源于领测软件测试网 https://www.ltesting.net/


关于领测软件测试网 | 领测软件测试网合作伙伴 | 广告服务 | 投稿指南 | 联系我们 | 网站地图 | 友情链接
版权所有(C) 2003-2010 TestAge(领测软件测试网)|领测国际科技(北京)有限公司|软件测试工程师培训网 All Rights Reserved
北京市海淀区中关村南大街9号北京理工科技大厦1402室 京ICP备2023014753号-2
技术支持和业务联系:info@testage.com.cn 电话:010-51297073

软件测试 | 领测国际ISTQBISTQB官网TMMiTMMi认证国际软件测试工程师认证领测软件测试网