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里面好像放的是全部的账号信息.每次发送
所有人得到的是一样的
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里面好像放的是全部的账号信息.每次发送
所有人得到的是一样的
解决方案 »
- delphi前景?
- 请高手指点这是何种加密算法得来
- 关于Indy的多线程。
- 下面这句话为何编译不能通过?
- 经典sql查询求助,有案例,帮忙解决一下!
- 喜欢Eiffel语言的朋友团结起来!!!!!!
- 关于win2000与win98下窗口字体设置的统一问题,在线等待
- 急问:奇怪,为何不能动态设置DBCombobox组件的Items值?
- 设计模式综述
- fastreport为什么不能统计记录条数count(id)?万分紧急!在线听答!!!!!!!!!!!!!!
- 在线等待:delpi idudp(c/s)如何获取服务端文件列表,存入到listview或者其他控件中。不用FTP。
- c/s 访问速度慢的问题?
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;
程序运行时会执行这个
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);我想知道上面那个函数能不能改成只查个人相关的账号信息,,反正就是这点不大懂,朋友帮帮忙呀..
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监听不管用了,,僵哥帮忙呀