用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);
  }
}
}

你可能感兴趣的:(C++,c,脚本,C#)