PEmployee = ^Employee;
  Employee = record
      ID,                          
      BranchID        :Integer;    
      LoginName,                   
      Password        :String[20]; 
      Name            :String[20]; 
      Sex             :String[1];  
      State           :String[20]; 
      ToolTips        :String[100];
      IsMe            :Boolean;    
      LocalIP         :String[15]; 
      LocalPort       :Integer;    
      IP              :String[15]; 
      Port            :Integer;    
      MACNO           :String[30]; 
      HaveAudioDevice,             
      HaveVideoDevice :Boolean;    
      LastActive      :Cardinal;   
      Position        :Integer;    
      Node            :TTreeNode;
      AThread         :TIdPeerThread;
      MySocket        :TMySocket;
  end;这个存放信息的employees老是神出鬼么,我很想知道,他这个东西起什么作用,用户的socket之类的信息有没有放在里面,
还有就是,如果像QQ那样,每个账号所得到的信息不是相同的怎么办,employees里面好像放的是全部的账号信息.每次发送
所有人得到的是一样的

解决方案 »

  1.   

      Employee = record 
          ID,                        //用户唯一标识号,相当于QQ号,这里可能是员工工号
          BranchID        :Integer;  //用户分支号,这个关键看如何确定,这里可能是员工的部门编号   
          LoginName,                 //用户的登录名   
          Password        :String[20];//密码  
          Name            :String[20];//姓名  
          Sex             :String[1]; //性别  
          State           :String[20];//状态  
          ToolTips        :String[100];//个性签名, 
          IsMe            :Boolean;    //客户端内部使用,标识是否是自己 
          LocalIP         :String[15]; //本地IP(P2P时使用)
          LocalPort       :Integer;    //本地端口(P2P时使用) 
          IP              :String[15]; //IP 
          Port            :Integer;    //端口 
          MACNO           :String[30]; //网卡MAC地址 
          HaveAudioDevice,             //是否检测到声音设备
          HaveVideoDevice :Boolean;    //是否检测到视频设备,比如摄像头
          LastActive      :Cardinal;   //最后通讯时间
          Position        :Integer;    //位置(程序内部使用) 
          Node            :TTreeNode;  //树形结构节点(程序内部使用)
          AThread         :TIdPeerThread;//线程(程序内部使用) 
          MySocket        :TMySocket; //通讯Socket(P2P时使用)
      end; 
      

  2.   

    二楼的朋友非常感谢,我是想知道:Employees :TThreadList;这个employees..原代码里是从数据库里查出几条字段并放在里面的,在有人连接后又添加相应的值,程序设计成了每个注册用户所得到了账号列表是一样的(都是直接把employees数据发过去),这就和QQ不一样了,有个人非要让我把它改成跟QQ差不多的,对于每一个用户来说,当然不能要EMPLOYEES里所有的数据了,不晓得这里该怎么办
      

  3.   

    如果是作为企业IM,当然是所有用户都一样,因为这里面所有的人都属于企业的员工,于是他都有权限联系。而你如果要按QQ的做法,就得有一个好友的管理,也就是相对任何一个账户还需要有相关联的“好友”表。
      

  4.   

    是,那人就是要让我改成那样的...呵呵...但是我有点不大懂改不动了:
    程序运行时会执行这个
    procedure TMainForm.GetBranchsAndEmployees();
    var
      ADODataSet:TADODataSet;
      EmployeeData:PEmployee;
      BranchData:PBranch;
      TempEmployees:TThreadList;
      iLoop,jLoop,kLoop:Integer;
      NewClient,Client:PEmployee;
      Find:Boolean;
      CBLoginResult:TCBLoginResult;
      Buffer:Array [1..2048] of Char;
    begin
      TempEmployees:=TThreadList.Create;
      with Employees.LockList do
      try
        for iLoop:=0 to Count-1 do
        begin
          TempEmployees.Add(Items[iLoop]);
        end;
      finally
        Employees.UnlockList;
      end;  ADODataSet:=TADODataSet.Create(nil);
      Branchs.LockList;
      Employees.LockList;
      try
        ADODataSet.Connection:=ADOConnection;
        ADODataSet.CommandText:='SELECT * From '+TB_Group;
        ADODataSet.Open;
        Branchs.Clear;
        Employees.Clear;
        while not ADODataSet.Eof do
        begin
            GetMem(BranchData,SizeOf(Branch));
            BranchData.ID:=ADODataSet.FieldByName(PB_GroupId).AsInteger;
            BranchData.Name:=TRIM(ADODataSet.FieldByName(PB_GroupName).AsString);
            BranchData.Node:=nil;
            Branchs.Add(BranchData);
            ADODataSet.Next;
        end;
        ADODataSet.Close;
        ADODataSet.CommandText:='SELECT '+PB_UserId+','
                               +PB_UserLoginName+','
                               +PB_UserPassWord+','
                               +PB_UserName+' From '
                               +TB_User;
        ADODataSet.Open;
        while not ADODataSet.Eof do
        begin
            GetMem(EmployeeData,SizeOf(Employee));
            EmployeeData.ID       :=ADODataSet.FieldByName(PB_UserId).AsInteger;
            EmployeeData.Name:=TRIM(ADODataSet.FieldByName(PB_UserName).AsString);
            EmployeeData.LoginName:=TRIM(ADODataSet.FieldByName(PB_UserLoginName).AsString);
            EmployeeData.Password:=TRIM(ADODataSet.FieldByName(PB_UserPassWord).AsString);        EmployeeData.LocalIP:='';
            EmployeeData.LocalPort:=0;
            EmployeeData.IP:='';
            EmployeeData.Port:=0;
            EmployeeData.LastActive:=0;
            EmployeeData.State:='断开';
            EmployeeData.Sex:='M';
            EmployeeData.Node:=nil;
            EmployeeData.AThread:=nil;
            Employees.Add(EmployeeData);
            ADODataSet.Next;
        end;    with TempEmployees.LockList do
        try
          for jLoop:=Count-1 downto 0 do
          begin
            Client:=Items[jLoop];
            Find:=false;
            with Employees.LockList do
            try
              for kLoop:=Count-1 downto 0 do
              begin
                NewClient:=Items[kLoop];
                if Client^.ID = NewClient^.ID then
                begin
                  NewClient^.LocalIP:=Client^.LocalIP;
                  NewClient^.LocalPort:=Client^.LocalPort;
                  NewClient^.State:=Client^.State;
                  NewClient^.IP:=Client^.IP;
                  NewClient^.Port:=Client^.Port;
                  NewClient^.HaveAudioDevice:=Client^.HaveAudioDevice;
                  NewClient^.HaveVideoDevice:=Client^.HaveVideoDevice;
                  NewClient^.LastActive:=Client^.LastActive;
                  NewClient^.AThread:=Client^.AThread;
                  Find:=True;
                  break;
                end;
              end;
            finally
              Employees.UnlockList;
            end;        if (not Find) and (Client^.State<>'断开') and (Client^.Port<>0) then
            begin
              //帐号已被删除,踢!
              CBLoginResult.IsLogin:=False;
              CBLoginResult.Result:=UserIsDeleted;
              Buffer[1]:=skLoginResult;
              CopyMemory(@Buffer[2],@CBLoginResult,SizeOf(CBLoginResult));
              ServerUDP.SendBuffer(Client^.IP,Client^.Port,Buffer,SizeOf(CBLoginResult)+1);
            end;        FreeMem(Client,SizeOf(Employee));
          end;
        finally
          TempEmployees.UnlockList;
        end;  finally
        Branchs.UnLockList;
        Employees.UnLockList;
        ADODataSet.Close;
        ADODataSet.Free;
        ADOConnection.Close;
      end;
    end;
    然后会根据这句读里面的数据作相应的操作
    AThread.Synchronize(GetBranchsAndEmployees);我想知道上面那个函数能不能改成只查个人相关的账号信息,,反正就是这点不大懂,朋友帮帮忙呀..
      

  5.   

    改了不成,,唉,其他地方还会用到
    function TMainForm.FindClientByAThread(AThread:TIdPeerThread):PEmployee;
    var
      iLoop:Integer;
    begin
        Result:=nil;
        with Employees.LockList do
        try
          for iLoop:=0 to count-1 do
          begin
            if PEmployee(Items[iLoop]).AThread=AThread then
            begin
              Result:=PEmployee(Items[iLoop]);
              exit;
            end;
          end;
        finally
          Employees.UnlockList;
        end;
    end;而且改了只能登录一个人另一个就吊在那里不动了,server监听不管用了,,僵哥帮忙呀