用FCC实现的聊天脚本

client
-----------------------------------------
class talkwnd:wnd{
RegClientGroup();
autowidth=100;
autoheight=100;
bk:=color(#003300);
obj m_pMain;
class richtext:textdoc{
  pos=8,8;
  autowidth=100,-16;
  autoheight=100,-52;
  bk:=round(#FFCC66,-4,-4,8,1);
  obj m_pScroll=new listscroll;
  void OnViewChanged(){
   m_pScroll.OnViewChge();
  }
  void OnAdd(string txt){
   addline=txt;
   viewoffset=0,50000;
  }
}
obj m_pSayText;
class say:text{
  src="Say:";
  xpos=5;
  valign=100,-30;
};
m_pSayText=new say;

class input:edit{
  maxnum=80;
  xpos=40;
  height=16;
  autowidth=100,-50;
  valign=100,-32;
  bk~a:=color(#333399);
  bk:=rect(0,#3333CC);
  void OnEnter(){
   pid.m_pMain.TalkTo(src);
   src="";
  }
}
class 通讯:socketc{
  defcreatewnd=pid;
  userinfo="talk","user","dj"+str(rand(100)),"123";
  c;
  c;
};
obj m_pList=new richtext;
obj m_pEdit=new input;
obj m_pSocketc=new 通讯;

class 其他用户:wnd{
  string m_sUserName;
  void NetTalk(string talker,string msg){
   string txt="\#FFFFCC"+talker+"说:\#FFFF00"+msg;
   pid.m_pList.OnAdd(txt);
  }
  void RemoteCreate(string username,string group){
   m_sUserName=username;
   string msg;
   msg=m_sUserName+"来了";
   pid.m_pList.OnAdd(msg);
  }
  void OnDestroy()
  {
   string msg;
   msg=m_sUserName+"走了";
   pid.m_pList.OnAdd(msg);
  }
}
class 用户:其他用户{
  pid.m_pMain=this;
  void TalkTo(string msg){
   tos<<OnTalk(m_sUserName,msg);
  }
  void CreatePlayer(string username){
   m_sUserName=username;
  }
  void OnTestMsg(var v)
  {
   pid.m_pList.OnAdd(v.type+v.str);
  }
  void Test(){
   var v=(1,2,3,"aaa");
   tos<<OnTest(v);
  }
}
new CmdBtn("List","pid.m_pMain.Test()");
}
bk:=null;
<talkwnd>;
--------------------------------------------------------
server
----------------------------------------------------------
<wnd>{
obj m_pServer=new sockets;
m_pServer.start=11000;
pid.style='font-size:10px'00,120;
size=pid.size;
RegWebGroup(m_pServer,"talk");
class user:wnd{
  string m_sMyname;
  void OnTalk(string talker,string msg)
  {
   tog<<NetTalk(talker,msg);
  }
  var Create()
  {
   return ("RemoteCreate",m_sMyname,"talk");
  }
  void OnWebPlayerCreate(string username,string pass,string address,string extmsg)
  {
   m_sMyname=username;
   RegWebPlayer("用户");
   toc<<CreatePlayer(username);
   RegWebObj("其他用户","Create");
  }
  void OnTest(var v)
  {
   toc<<OnTestMsg(v);
  }
}
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值