| 订阅 | 在线投稿
分享
 
 
当前位置: 王朝网络 >> delphi >> Delphi kai fa ji yu DCOM de liao tian shi
 

Delphi kai fa ji yu DCOM de liao tian shi

2008-06-01 01:57:58 编辑來源:互联网 评论
 
本文为【Delphi开发基于DCOM的聊天室】的拼音翻译版
  fen bu shi COM( yi xia jian cheng DCOM) de chu xian gei wo men qing song de chuang jian fen bu shi ying yong ti gong le ji hui ; wo men ke yi wan quan bu qu li hui di ji bie de Windows Sockets(DCOM tong guo MS-RPC rang ke hu yu dui xiang jin xing tong xin , xing yun de shi yao kai fa COM ying yong , kai fa zhe ji hu ke yi bu qu li hui MS-RPC) er kai fa chu gong neng qiang da 、 ou he xing di ( gong neng mo kuai xiang dui du li ,
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  hen hao de fa hui le OO de si xiang )、 yi yu bu shu de fen bu shi ji suan xi tong 。
  ben wen wo men da suan shi yong DCOM lai kai fa yi ge ju yu wang liao tian shi , bu jin shi zuo wei ji shu shang de yan jiu , shi ji shang wo xiang xin zhe ying gai ye shi yi ge you yong de gong ju 。 shou xian wo men yao dui zhe ge liao tian shi de gong neng you yi ge da zhi de le jie :
  1、 zhi shao zhe ge liao tian shi ying gai da ying duo ge ju yu wang yong hu jin xing liao tian 。
  2、 ying gai neng gou you duo ge hua ti de zi liao tian shi , yong hu ke yi xuan ze jin ru mou ge liao tian shi jin xing liao tian 。
  3、 ke hu duan ying gai jin liang jian dan ( bu yong pei zhi DCOM), bing xu yao yi ge fu wu qi duan zhi li suo you de jiao hu xing wei , zhi li liao tian shi de shu mu he xiang guan pei zhi , bing zuo hao xi tong jian ce he ri zhi ji lu deng 。
  4、 dui liao tian shi gong neng jin xing kuo zhan ( ru jing jing hua gong neng , biao qing fu hao deng )。 gen ju yi shang de gong neng miao shu , zai zai xi fen xi wen ti yi hou wo men she ji chu xia mian de cao tu :
Delphi开发基于DCOM的聊天室

  zhe pian wen zhang zhong wo men yao da zhi shi xian zhe ge cheng xu de yi ge ji ben de gai xin , bao kuo IChatManager、TChatRoomManager、TchatRoom, wan cheng yi ge zui ji ben gong neng de fu wu qi duan , bing zuo yi ge jian dan de ke hu duan jin xing jian ce 。 wo men de chong dian shi fu wu qi duan , yin wei ta jiang shi xian liao tian shi de da bu fen gong neng , ke hu duan zhi shi yi ge shi fen xiao qiao jian dan de cheng xu 。
  you yu pian fu guan xi , wo men zhi lie chu chong yao de bu fen de dai ma , wan zheng de cheng xu qing gei wo fa email。 shou xian lai kan kan wo men de IchatManager jie kou shi shen me yang zi :
  
  IChatManager = interface(IDispatch)
  ['{E7CD7F0D-447F-497A-8C7B-1D80E748B67F}']
  PRocedure SpeakTo(const content: WideString; destid: Integer); safecall;
  // ke hu xiang zhi ding de fang jian shuo hua ,destid wei fang jian hao
  function ReadFrom(sourceid: Integer): IStrings; safecall;
  // ke hu cong zhi ding de fang jian du qu tan hua nei rong ,sourceid wei fang jian hao
  function ReadReady(id: Integer): Byte; safecall;
  // ke hu jian ce zhi ding de fang jian shi fou yi jing ke yi du qu tan hua nei rong
  procedure ConnectRoom(const UserName: WideString; RoomID: Integer); safecall;
  // ke hu deng lu zhi ding fang jian
  procedure DisconnectRoom(const UserName: WideString; RoomID: Integer); safecall;
  // ke hu tui chu zhi ding fang jian
  function TestClearBufferTag(RoomID: Integer): Integer; safecall;
  // ke hu ce shi zhi ding fang jian de huan chong qu de qing kong yu fou zhuang kuang
  end;
  zai lai kan kan jie kou de shi xian lei TChatManager bu fen :
  type
  TChatManager = class(TAutoObject, IChatManager)
  protected
  function ReadFrom(sourceid: Integer): IStrings; safecall;
  // zai zhe li wo men shi yong Delphi kuo zhan de fu duo lei xing TStings, wei le rang COM zhi chi zhe zhong
  // lei xing ,delphi ti gong le IStrings jie kou
  procedure SpeakTo(const content: WideString; destid: Integer); safecall;
  function ReadReady(id: Integer): Byte; safecall;
  // yong lai ti gong gei ke hu duan cha xun zhi ding de fang jian shi fou ke du , ji zhi ding fang jian huan chong qu shi fou wei kong
  procedure ConnectRoom(const UserName: WideString; RoomID: Integer);
  safecall;
  procedure DisconnectRoom(const UserName: WideString; RoomID: Integer);
  safecall;
  function TestClearBufferTag(RoomID: Integer): Integer; safecall;
  end;
  shi xian bu fen :
  
  
  function TChatManager.ReadFrom(sourceid: Integer): IStrings;
  var
  TempRoom:TChatRoom;
  begin
  TempRoom:=ChatRoomManager.FindRoomByID(sourceid);
  while TempRoom.Locked do
  begin
  //do nothing zhi shi deng dai jie suo
  end;
  GetOleStrings(TempRoom.OneRead,Result);
  end;
  procedure TChatManager.SpeakTo(const content: WideString; destid: Integer);
  var
  TempRoom:TChatRoom;
  begin
  TempRoom:=ChatRoomManager.FindRoomByID(destid);
  while TempRoom.Locked do
  begin
  //do nothing zhi shi deng dai jie suo
  end;
  TempRoom.OneSpeak(content);
  end;
  function TChatManager.ReadReady(id: Integer): Byte;
  var
  TempRoom:TChatRoom;
  begin
  TempRoom:=ChatRoomManager.FindRoomByID(id);
  if TempRoom.CanRead then result:=1 else Result:=0;
  end;
  procedure TChatManager.ConnectRoom(const UserName: WideString;
  RoomID: Integer);
  // ke hu duan tong guo jie kou deng lu dao zhi ding de fang jian , mei you wan quan shi xian
  var
  TempRoom:TChatRoom;
  begin
  TempRoom:=ChatRoomManager.FindRoomByID(RoomID);
  TempRoom.LoginRoom(UserName);
  end;
  procedure TChatManager.DisconnectRoom(const UserName: WideString;
  RoomID: Integer);
  // ke hu duan tong guo jie kou li kai zhi ding de fang jian , mei you wan quan shi xian
  var
  TempRoom:TChatRoom;
  begin
  TempRoom:=ChatRoomManager.FindRoomByID(RoomID);
  TempRoom.LeaveRoom(UserName);
  end;
  function TChatManager.TestClearBufferTag(RoomID: Integer): Integer;
  var
  TempRoom:TChatRoom;
  begin
  TempRoom:=ChatRoomManager.FindRoomByID(RoomID);
  result:=TempRoom.ClearBufferTag;
  end;
  initialization
  TAutoObjectFactory.Create(ComServer, TChatManager, Class_ChatManager,
  ciMultiInstance, tmApartment);
  end.
  bi jiao yao hai TchatRoom shi xia mian de yang zi :
  
  type
  TChatRoom=class
  private
  FBuffer:array[1..20] of string;
  FBufferLength:integer;
  FRoomName:string;
  FRoomID:integer;
  FLocked:boolean;// tong bu suo , yong lai chu li duo ren tong shi fa chu dui hua de qing kuang
  FConnectCount:integer;// dang qian fang jian de ren shu
  FClearBufferTag:integer;
  // mei qing kong yi ci buffer ci zhi bian tiao bian yi ci , ci mai chong bei ke hu duan jian ce
  protected
  procedure ClearBuffer;// qing kong huan chong qu
  function GetCanRead:boolean;
  public
  constrUCtor Create(RoomName:string;RoomID:integer);
  procedure OneSpeak(content:string);// jiang yi tiao liao tian nei rong jia ru huan chong qu
  procedure LoginRoom(UserName:string);// shen kan shi xian bu fen zhu shi
  procedure LeaveRoom(UserName:string);// shen kan shi xian bu fen zhu shi
  function OneRead:Tstrings;// cong huan chong qu zhong du chu ji lu
  property Locked:boolean read FLocked; //readonly;// gong IChatManager jian ce
  property CanRead:boolean read GetCanRead;// pan ding huan chong qu shi fou wei kong , fou ze shi bu ke du de
  property ClearBufferTag:integer read FClearBufferTag;
  end;
  TchatRoom de shi xian :
  { TChatRoom }
  constructor TChatRoom.Create(RoomName:string;RoomID:integer);
  begin
  FBufferLength:=0;
  FConnectCount:=0;
  FClearBufferTag:=1;
  FLocked:=false;
  FRoomName:=RoomName;
  FRoomID:=RoomID;
  end;
  procedure TChatRoom.ClearBuffer;
  var
  i:integer;
  begin
  /// zai zhe li ke yi jian ce yi ge biao zhi , pan ding shi fou xu yao fu wu qi ji lu mei yi ci liao tian nei rong
  for i:=1 to 20 do
  FBuffer[i]:='';
  FBufferLength:=0;
  FClearBufferTag:=0-FClearBufferTag;
  end;
  procedure TChatRoom.OneSpeak(content:string);
  begin
  FLocked:=true;
  inc(FBufferLength);
  if FBufferLength>20 then
  begin
  ClearBuffer;
  inc(FBufferLength);
  end;
  FBuffer[FBufferLength]:=content;
  FLocked:=false;
  end;
  function TChatRoom.OneRead:TStrings;
  var
  FStrings:TStrings;
  i:integer;
  begin
  FLocked:=true;
  FStrings:=TStringList.Create;
  for i:=1 to FBufferLength do
  FStrings.Add(FBuffer[i]);
  result:=FStrings;
  FLocked:=false;
  end;
  function TChatRoom.GetCanRead: boolean;
  begin
  result:=false;
  if FBufferLength>0 then result:=true;
  end;
  procedure TChatRoom.LoginRoom(UserName:string);
  // yong hu deng lu liao tian shi shi jian , zhe li mei you wan quan shi xian
  begin
  inc(FConnectCount);
  end;
  procedure TChatRoom.LeaveRoom(UserName: string);
  // yong hu li kai liao tian shi shi jian , zhe li mei you wan quan shi xian
  begin
  Dec(FConnectCount);
  end;
  fu wu qi duan de zui hou yi ge bi jiao chong yao de bu fen TchatRoomManager:
  type
  TChatRoomManager=class
  private
  ChatRoom:array of TChatRoom;
  public
  constructor Create;
  function FindRoomByID(id:integer):TChatRoom;
  end;
  shi xian bu fen :
  { TChatRoomManager }
  constructor TChatRoomManager.Create;
  var
  i,RoomCount:integer;
  RoomNames:TStrings;//RoomName shi pei zhi wen jian zhong de liao tian shi ming cheng
  begin
  RoomCount:=1;
  // zhe li jiang cong pei zhi wen jian zhong du chu you ji ge liao tian shi
  RoomNames:=TStringList.Create;
  RoomNames.Add('TestRoom');// zhe ju jiang bei zui zhong de cong pei zhi wen jian du qu ti huan diao
  setlength(ChatRoom,RoomCount);
  for i:=1 to RoomCount do
  ChatRoom[i]:=TChatRoom.Create(RoomNames[i-1],i);
  end;
  function TChatRoomManager.FindRoomByID(id:integer): TChatRoom;
  // gai han shu you IChatManager jie kou tiao yong , you yu zui zhong ban ben de jie kou jiang hui ti gong gei ke hu
  // duan de dao fang jian lie biao de gong neng , suo yi ke hu duan zhi dao zi ji fang jian de id
  begin
  result:=ChatRoom[id];
  end;
  initialization
  ChatRoomManager:=TChatRoomManager.Create;
  end.
  
  
  
  zai fu wu qi duan de zhu yao gai xin bu fen wan cheng yi hou , wo men pei zhi hao fu wu qi duan de DCOM pei zhi , jiu ke yi kai fa yi ge jian dan de ke hu duan jin xing ce shi le :( sui ran ke hu duan jin ke neng de jian dan , wo men bu yong pei zhi DCOM dan wo men reng xu yao kao bei fu wu qi duan de lei xing ku wen jian .tlb dao ke hu duan bing zhu ce hou cai neng kai fa he shi yong ke hu duan , dang ran , zhe xie dou ke yi tong guo an zhuang cheng xu lai wan cheng )
  zai ke hu duan wo men zhi lie chu liang ge xiang dui chong yao de han shu , qi yu de dou sheng lue , qing xiang wo lai xin huo de quan bu de cheng xu :
  
  procedure TForm1.Button1Click(Sender: TObject);
  // dian ji button1 hou jiang edit de nei rong “ shuo ” chu qu
  begin
  Server.SpeakTo(edit1.Text,1);
  end;
  procedure TForm1.Timer1Timer(Sender: TObject);
  // mei ge yi duan shi jian xiang fu wu qi qing qiu tan hua nei rong , wo she zhi le wei 1.5 miao
  var
  TempStrings:TStrings;
  i:integer;
  begin
  if Server.ReadReady(1)=1 then
  begin
  TempStrings:=TStringList.Create;
  SetOleStrings(TempStrings,Server.ReadFrom(1));
  if FReadStartPos>19 then
  if (FClearBufferTag=0-Server.TestClearBufferTag(1)) then
  begin
  FReadStartPos:=0;
  FClearBufferTag:=Server.TestClearBufferTag(1);
  end;
  for i:=FReadStartPos to TempStrings.Count-1 do
  Memo1.Lines.Add(TempStrings[i]);
  FReadStartPos:=TempStrings.Count;
  end;
  end;
  yi ge ji yu DCOM de ju yu wang liao tian shi de gai xin bu fen jiu ji ben wan cheng le , bing qie suo you de ce shi dou bi jiao shun li , zhe li xu yao bu chong shuo ming yi xia liao tian shi fu wu qi de yi ge nan dian : jiu shi xu yao kai fa zhe fei chang jin shen de chu li tong bu , sui ran wo ye jin xing le yi ding de tong bu chu li , dan zai ke hu duan ren shu zhong duo de qing kuang xia reng ran ke neng fa sheng si suo huo qi ta huo suo de qing kuang , zhe ge cheng xu huan xu yao geng jin yi bu de ce shi 、 shen zhi jin xing yi ding de chong gou 。【原文】【汉音对照
 
 
 
 
 
 
 
 
日版宠物情人插曲《Winding Road》歌词

日版宠物情人2017的插曲,很带节奏感,日语的,女生唱的。 最后听见是在第8集的时候女主手割伤了,然后男主用嘴帮她吸了一下,插曲就出来了。 歌手:Def...

兄弟共妻,我成了他们夜里的美食

老钟家的两个儿子很特别,就是跟其他的人不太一样,魔一般的执着。兄弟俩都到了要结婚的年龄了,不管自家老爹怎么磨破嘴皮子,兄弟俩说不娶就不娶,老父母为兄弟两操碎了心...

如何磨出破洞牛仔裤?牛仔裤怎么剪破洞?

把牛仔裤磨出有线的破洞 1、具体工具就是磨脚石,下面垫一个硬物,然后用磨脚石一直磨一直磨,到把那块磨薄了,用手撕开就好了。出来的洞啊很自然的。需要猫须的话调几...

我就是扫描下图得到了敬业福和爱国福

先来看下敬业福和爱国福 今年春节,支付宝再次推出了“五福红包”活动,表示要“把欠大家的敬业福都还给大家”。 今天该活动正式启动,和去年一样,需要收集“五福”...

冰箱异味产生的原因和臭味去除的方法

有时候我们打开冰箱就会闻到一股异味,冰箱里的这种异味是因为一些物质发出的气味的混合体,闻起来让人恶心。 产生这些异味的主要原因有以下几点。 1、很多人有这种习...

 
 
   fen bu shi COM( yi xia jian cheng DCOM) de chu xian gei wo men qing song de chuang jian fen bu shi ying yong ti gong le ji hui ; wo men ke yi wan quan bu qu li hui di ji bie de Windows Sockets(DCOM tong guo MS-RPC rang ke hu yu dui xiang jin xing tong xin , xing yun de shi yao kai fa COM ying yong , kai fa zhe ji hu ke yi bu qu li hui MS-RPC) er kai fa chu gong neng qiang da 、 ou he xing di ( gong neng mo kuai xiang dui du li , hen hao de fa hui le OO de si xiang )、 yi yu bu shu de fen bu shi ji suan xi tong 。    ben wen wo men da suan shi yong DCOM lai kai fa yi ge ju yu wang liao tian shi , bu jin shi zuo wei ji shu shang de yan jiu , shi ji shang wo xiang xin zhe ying gai ye shi yi ge you yong de gong ju 。 shou xian wo men yao dui zhe ge liao tian shi de gong neng you yi ge da zhi de le jie :   1、 zhi shao zhe ge liao tian shi ying gai da ying duo ge ju yu wang yong hu jin xing liao tian 。      2、 ying gai neng gou you duo ge hua ti de zi liao tian shi , yong hu ke yi xuan ze jin ru mou ge liao tian shi jin xing liao tian 。   3、 ke hu duan ying gai jin liang jian dan ( bu yong pei zhi DCOM), bing xu yao yi ge fu wu qi duan zhi li suo you de jiao hu xing wei , zhi li liao tian shi de shu mu he xiang guan pei zhi , bing zuo hao xi tong jian ce he ri zhi ji lu deng 。   4、 dui liao tian shi gong neng jin xing kuo zhan ( ru jing jing hua gong neng , biao qing fu hao deng )。 gen ju yi shang de gong neng miao shu , zai zai xi fen xi wen ti yi hou wo men she ji chu xia mian de cao tu : [url=http://www.wangchao.net.cn/bbs/pydetail_1785096.html][img]http://image.wangchao.net.cn/it/1323424723276.jpg[/img][/url]    zhe pian wen zhang zhong wo men yao da zhi shi xian zhe ge cheng xu de yi ge ji ben de gai xin , bao kuo IChatManager、TChatRoomManager、TchatRoom, wan cheng yi ge zui ji ben gong neng de fu wu qi duan , bing zuo yi ge jian dan de ke hu duan jin xing jian ce 。 wo men de chong dian shi fu wu qi duan , yin wei ta jiang shi xian liao tian shi de da bu fen gong neng , ke hu duan zhi shi yi ge shi fen xiao qiao jian dan de cheng xu 。    you yu pian fu guan xi , wo men zhi lie chu chong yao de bu fen de dai ma , wan zheng de cheng xu qing gei wo fa email。 shou xian lai kan kan wo men de IchatManager jie kou shi shen me yang zi : IChatManager = interface(IDispatch) ['{E7CD7F0D-447F-497A-8C7B-1D80E748B67F}'] PRocedure SpeakTo(const content: WideString; destid: Integer); safecall; // ke hu xiang zhi ding de fang jian shuo hua ,destid wei fang jian hao function ReadFrom(sourceid: Integer): IStrings; safecall; // ke hu cong zhi ding de fang jian du qu tan hua nei rong ,sourceid wei fang jian hao function ReadReady(id: Integer): Byte; safecall; // ke hu jian ce zhi ding de fang jian shi fou yi jing ke yi du qu tan hua nei rong procedure ConnectRoom(const UserName: WideString; RoomID: Integer); safecall; // ke hu deng lu zhi ding fang jian procedure DisconnectRoom(const UserName: WideString; RoomID: Integer); safecall; // ke hu tui chu zhi ding fang jian function TestClearBufferTag(RoomID: Integer): Integer; safecall; // ke hu ce shi zhi ding fang jian de huan chong qu de qing kong yu fou zhuang kuang end; zai lai kan kan jie kou de shi xian lei TChatManager bu fen : type TChatManager = class(TAutoObject, IChatManager) protected function ReadFrom(sourceid: Integer): IStrings; safecall; // zai zhe li wo men shi yong Delphi kuo zhan de fu duo lei xing TStings, wei le rang COM zhi chi zhe zhong // lei xing ,delphi ti gong le IStrings jie kou procedure SpeakTo(const content: WideString; destid: Integer); safecall; function ReadReady(id: Integer): Byte; safecall; // yong lai ti gong gei ke hu duan cha xun zhi ding de fang jian shi fou ke du , ji zhi ding fang jian huan chong qu shi fou wei kong procedure ConnectRoom(const UserName: WideString; RoomID: Integer); safecall; procedure DisconnectRoom(const UserName: WideString; RoomID: Integer); safecall; function TestClearBufferTag(RoomID: Integer): Integer; safecall; end;    shi xian bu fen : function TChatManager.ReadFrom(sourceid: Integer): IStrings; var TempRoom:TChatRoom; begin TempRoom:=ChatRoomManager.FindRoomByID(sourceid); while TempRoom.Locked do begin //do nothing zhi shi deng dai jie suo end; GetOleStrings(TempRoom.OneRead,Result); end; procedure TChatManager.SpeakTo(const content: WideString; destid: Integer); var TempRoom:TChatRoom; begin TempRoom:=ChatRoomManager.FindRoomByID(destid); while TempRoom.Locked do begin //do nothing zhi shi deng dai jie suo end; TempRoom.OneSpeak(content); end; function TChatManager.ReadReady(id: Integer): Byte; var TempRoom:TChatRoom; begin TempRoom:=ChatRoomManager.FindRoomByID(id); if TempRoom.CanRead then result:=1 else Result:=0; end; procedure TChatManager.ConnectRoom(const UserName: WideString; RoomID: Integer); // ke hu duan tong guo jie kou deng lu dao zhi ding de fang jian , mei you wan quan shi xian var TempRoom:TChatRoom; begin TempRoom:=ChatRoomManager.FindRoomByID(RoomID); TempRoom.LoginRoom(UserName); end; procedure TChatManager.DisconnectRoom(const UserName: WideString; RoomID: Integer); // ke hu duan tong guo jie kou li kai zhi ding de fang jian , mei you wan quan shi xian var TempRoom:TChatRoom; begin TempRoom:=ChatRoomManager.FindRoomByID(RoomID); TempRoom.LeaveRoom(UserName); end; function TChatManager.TestClearBufferTag(RoomID: Integer): Integer; var TempRoom:TChatRoom; begin TempRoom:=ChatRoomManager.FindRoomByID(RoomID); result:=TempRoom.ClearBufferTag; end; initialization TAutoObjectFactory.Create(ComServer, TChatManager, Class_ChatManager, ciMultiInstance, tmApartment); end.    bi jiao yao hai TchatRoom shi xia mian de yang zi : type TChatRoom=class private FBuffer:array[1..20] of string; FBufferLength:integer; FRoomName:string; FRoomID:integer; FLocked:boolean;// tong bu suo , yong lai chu li duo ren tong shi fa chu dui hua de qing kuang FConnectCount:integer;// dang qian fang jian de ren shu FClearBufferTag:integer; // mei qing kong yi ci buffer ci zhi bian tiao bian yi ci , ci mai chong bei ke hu duan jian ce protected procedure ClearBuffer;// qing kong huan chong qu function GetCanRead:boolean; public constrUCtor Create(RoomName:string;RoomID:integer); procedure OneSpeak(content:string);// jiang yi tiao liao tian nei rong jia ru huan chong qu procedure LoginRoom(UserName:string);// shen kan shi xian bu fen zhu shi procedure LeaveRoom(UserName:string);// shen kan shi xian bu fen zhu shi function OneRead:Tstrings;// cong huan chong qu zhong du chu ji lu property Locked:boolean read FLocked; //readonly;// gong IChatManager jian ce property CanRead:boolean read GetCanRead;// pan ding huan chong qu shi fou wei kong , fou ze shi bu ke du de property ClearBufferTag:integer read FClearBufferTag; end; TchatRoom de shi xian : { TChatRoom } constructor TChatRoom.Create(RoomName:string;RoomID:integer); begin FBufferLength:=0; FConnectCount:=0; FClearBufferTag:=1; FLocked:=false; FRoomName:=RoomName; FRoomID:=RoomID; end; procedure TChatRoom.ClearBuffer; var i:integer; begin /// zai zhe li ke yi jian ce yi ge biao zhi , pan ding shi fou xu yao fu wu qi ji lu mei yi ci liao tian nei rong for i:=1 to 20 do FBuffer[i]:=''; FBufferLength:=0; FClearBufferTag:=0-FClearBufferTag; end; procedure TChatRoom.OneSpeak(content:string); begin FLocked:=true; inc(FBufferLength); if FBufferLength>20 then begin ClearBuffer; inc(FBufferLength); end; FBuffer[FBufferLength]:=content; FLocked:=false; end; function TChatRoom.OneRead:TStrings; var FStrings:TStrings; i:integer; begin FLocked:=true; FStrings:=TStringList.Create; for i:=1 to FBufferLength do FStrings.Add(FBuffer[i]); result:=FStrings; FLocked:=false; end; function TChatRoom.GetCanRead: boolean; begin result:=false; if FBufferLength>0 then result:=true; end; procedure TChatRoom.LoginRoom(UserName:string); // yong hu deng lu liao tian shi shi jian , zhe li mei you wan quan shi xian begin inc(FConnectCount); end; procedure TChatRoom.LeaveRoom(UserName: string); // yong hu li kai liao tian shi shi jian , zhe li mei you wan quan shi xian begin Dec(FConnectCount); end; fu wu qi duan de zui hou yi ge bi jiao chong yao de bu fen TchatRoomManager: type TChatRoomManager=class private ChatRoom:array of TChatRoom; public constructor Create; function FindRoomByID(id:integer):TChatRoom; end; shi xian bu fen : { TChatRoomManager } constructor TChatRoomManager.Create; var i,RoomCount:integer; RoomNames:TStrings;//RoomName shi pei zhi wen jian zhong de liao tian shi ming cheng begin RoomCount:=1; // zhe li jiang cong pei zhi wen jian zhong du chu you ji ge liao tian shi RoomNames:=TStringList.Create; RoomNames.Add('TestRoom');// zhe ju jiang bei zui zhong de cong pei zhi wen jian du qu ti huan diao setlength(ChatRoom,RoomCount); for i:=1 to RoomCount do ChatRoom[i]:=TChatRoom.Create(RoomNames[i-1],i); end; function TChatRoomManager.FindRoomByID(id:integer): TChatRoom; // gai han shu you IChatManager jie kou tiao yong , you yu zui zhong ban ben de jie kou jiang hui ti gong gei ke hu // duan de dao fang jian lie biao de gong neng , suo yi ke hu duan zhi dao zi ji fang jian de id begin result:=ChatRoom[id]; end; initialization ChatRoomManager:=TChatRoomManager.Create; end.    zai fu wu qi duan de zhu yao gai xin bu fen wan cheng yi hou , wo men pei zhi hao fu wu qi duan de DCOM pei zhi , jiu ke yi kai fa yi ge jian dan de ke hu duan jin xing ce shi le :( sui ran ke hu duan jin ke neng de jian dan , wo men bu yong pei zhi DCOM dan wo men reng xu yao kao bei fu wu qi duan de lei xing ku wen jian .tlb dao ke hu duan bing zhu ce hou cai neng kai fa he shi yong ke hu duan , dang ran , zhe xie dou ke yi tong guo an zhuang cheng xu lai wan cheng )    zai ke hu duan wo men zhi lie chu liang ge xiang dui chong yao de han shu , qi yu de dou sheng lue , qing xiang wo lai xin huo de quan bu de cheng xu : procedure TForm1.Button1Click(Sender: TObject); // dian ji button1 hou jiang edit de nei rong “ shuo ” chu qu begin Server.SpeakTo(edit1.Text,1); end; procedure TForm1.Timer1Timer(Sender: TObject); // mei ge yi duan shi jian xiang fu wu qi qing qiu tan hua nei rong , wo she zhi le wei 1.5 miao var TempStrings:TStrings; i:integer; begin if Server.ReadReady(1)=1 then begin TempStrings:=TStringList.Create; SetOleStrings(TempStrings,Server.ReadFrom(1)); if FReadStartPos>19 then if (FClearBufferTag=0-Server.TestClearBufferTag(1)) then begin FReadStartPos:=0; FClearBufferTag:=Server.TestClearBufferTag(1); end; for i:=FReadStartPos to TempStrings.Count-1 do Memo1.Lines.Add(TempStrings[i]); FReadStartPos:=TempStrings.Count; end; end;    yi ge ji yu DCOM de ju yu wang liao tian shi de gai xin bu fen jiu ji ben wan cheng le , bing qie suo you de ce shi dou bi jiao shun li , zhe li xu yao bu chong shuo ming yi xia liao tian shi fu wu qi de yi ge nan dian : jiu shi xu yao kai fa zhe fei chang jin shen de chu li tong bu , sui ran wo ye jin xing le yi ding de tong bu chu li , dan zai ke hu duan ren shu zhong duo de qing kuang xia reng ran ke neng fa sheng si suo huo qi ta huo suo de qing kuang , zhe ge cheng xu huan xu yao geng jin yi bu de ce shi 、 shen zhi jin xing yi ding de chong gou 。
󰈣󰈤
  免责声明:本文仅代表作者个人观点,与王朝网络无关。王朝网络登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述,其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
我们约会吧
漂亮白皙的模特
好纯好美的女生
靓丽的网络美女
痞子的甘南日记
疑是银河落九天
雪域坝上四——纯美色
冬日恋歌——西城杨柳弄轻柔
 
>>返回首页<<
 为你推荐
 
 
 转载本文
 UBB代码 HTML代码
复制到剪贴板...
 
 热帖排行
 
 
 
 
©2005- 王朝网络 版权所有