Internati o nal  Journal of Ele c trical   and Computer  Engineering  (IJE CE)  Vol .   5 ,  No . 3,  J une   2 0 1 5 ,  pp . 58 6~ 59 8   I S SN : 208 8-8 7 0 8           5 86     Jo urn a l  h o me pa ge : h ttp ://iaesjo u r na l.com/ o n lin e/ind e x.ph p / IJECE  Application-level Communication  Services for Development of  Social Networking Systems       Yun j i n   L e e * , Mi ng yu   L i m* *, Y a n g ch an Mo on * *   * Division of  Digital Media,  Ajou University , Korea  ** Depart em ent  of Intern et  & M u ltim edia  Eng i n eering ,  Konkuk  Universit y , Korea      Article Info    A B STRAC T Article histo r y:  Received  Ja n 16, 2015  Rev i sed  Ap 21 , 20 15  Accepte May 6, 2015      In this paper, we present our co mmunication middleware (C M), which is  designed to r e duce th e effor t  of develop i ng  common communication  function a li ties f o r social n e two r king servic es ( S NSs) in the c lient-s erver   model. SNS de velopers can apply   th e application-level communicatio n   services of CM both to an SNS  server  and to client applic at i ons si mply  by   calling  application programming interface s (APIs) and conf igur ing var i ous  options related to communicatio n servic es. CM  was develop e d to enab le SNS   develop e rs to  easily  build fund amenta l  s e rvi ces  s u ch as   trans m is s i on of a   us er-defined ev e n t, us er m e m b ers h ip and authent i ca tion m a nage m e nt, friend   management, content uplo a and downl oad with  differ e nt numbers  of   attachments, ch at management, and  direc t  file transf er. All of the   communication  services also provide op tions that a develop e r can  customize  accord ing to  his   or her  S N S  requi rem e nts . Keyword:  C l i e nt -serve r s y st em   C o m m uni cat i o n m i ddl eware   Co n t en t tran smissio n   Social net w orking  service  U s e r  me mb e r s h i p  ma n a g e me n t   Copyright ©  201 5 Institut e  o f   Ad vanced  Engin eer ing and S c i e nce.  All rights re se rve d Co rresp ond i ng  Autho r Min g yu Lim ,     Depa rtem ent of Internet  &  M u l t i m e di a Engi neeri n g ,   K onk uk  Un iv er sity,  1 2 0  N e u ngd ong -r o, G w a ng j i n- gu Seo u l  14 3- 701 , K o r ea.  Em a il: mli m @ k onk uk .ac.kr       1.   INTRODUCTION  As wi re d a n d  wi rel e ss net w o r k s  ha ve p r ol i f erat e d  and becom e  prevalent in our daily life, the  p r ev ailin g   n e t w ork in frastructu re en ab les  users  to easily create, process ,   and s h are s o c i al content a n ywhe re at  any  t i m e , usi ng v a ri o u s i n t e rnet -e na bl ed  devi ces s u c h  as deskt op  PC s,  l a pt op PC s ,  t a bl et  com put ers ,  an d   sm art phone s.  Am ong t h p o pul a r  ser v i ces i n  suc h  a n  en vi r onm ent  are soc i al  net w o r ki ng  servi ces  (S NSs ) , a n d   t h e num ber o f  SNSs a nd t h e i r users a r e g r owi n g .  De vel o pers  of e x i s t i n g SN Ss ha ve f o cu sed  pri m aril y  on   im pl em ent i ng vari ous c ont e n t  servi ces, b u t  t h ey  have o v e r l o o k ed t h e i n ef fi ci ency  of d e v e l opm ent  caused by   red u nda nt l y  pr ovi di n g  com m on c o m m uni cat i on ser v i ces.  Al t h o u gh  di f f e r ent  S N Ss ha ve bee n  de vel ope separat e l y , t h e y  have a  n u m ber of si m i lar com m uni ca tio n - related   fun c tio ns su ch   as u s er m e m b ersh i p au th en ticatio n ,  ev en t no tificatio n ,  sh a r i n o f  t e xt  m e ssage s o p t i o nal l y  h a vi n g   fi l e  at t achm e nt s, an di rect  cont e n t  t r a n sm i ssi on.     In t h i s   pa per,  we p r o p o se  ou r com m uni cat i on m i ddl eware (C M ) w h i c h aim s  t o  sup p o rt  t h e   devel opm ent  of s o ci al  net w o r ki n g  ser v i ces by  re d u ci ng t h e e f f o rt   req u i r e d  t o   de vel o p c o m m u n i cat i o n   servi ces . As a n  ap pl i cat i o n - l e vel  com m uni cat i on f r am ewor k, C M  p r o v i des SN S de v e l ope rs wi t h  s i m p l e   application programm ing interfaces  (A PIs) a n d confi g uration options  rela ted to c o mm unication service s  suc h   as arb itrary even t co m p o s ition  and  tran sm is sio n , u s er  m e m b ersh ip  and   au th en ticatio n ,  friend  m a n a ge m e n t cont e n t  sha r i n g, c h at  m a nagem e nt , and  di rect  fi l e  t r ansf er. Eac h  ser v i ce al so p r o v i d es opt i o ns  vi a  C M   co nfigu r ation s  o r  API call p a ram e ters to  cu sto m ize  the services for a variety of possi ble appl ication  requirem ents.  Evaluation Warning : The document was created with Spire.PDF for Python.
I J ECE   I S SN 208 8-8 7 0 8       Application-le vel Comm unic a tion Se rvices  for Developme nt  of  Social Ne tworking Sy stems   (Min gyu Li m )   58 7 The rem a i nder  of t h i s  pa pe r i s  orga ni ze d as  fol l o ws. I n  Se ct i on 2 ,  we s u rvey  exi s t i n m i ddl eware   syste m s for SNSs a n d com p are t h em  with our approa ch In   Sectio n   3 ,   we briefly  in trodu ce CM an d its  archi t ect u r e. I n  Sect i on  4, w e  descri be t h d e t a i l s  of h o C M  opt i o ns ca n be c o nfi g u r e d  i n  S N S se rv er an cl i e nt  appl i cat i ons . A f t e r we  prese n t  h o w a devel ope r can  in teg r ate CM in to  serv er an d   clien t  ap p licatio n s  in   Sect i on 5, we descri be  i n  det a i l   how  a p pl i cat i ons part i c ipate in  a CM n e twork  i n  Sectio n   6 .   In   Section  7, we  prese n t  t h e  C M  su pp ort  f u n c t i ons  fo r c o m m uni cat i on ser v i ces, a n wi t h  Sect i o n  8 ,   we  concl ude  t h e  p a per .       2.   RELATED WORK  There  have  be en som e  past  st udi es o n  m i ddl eware ser v i c e s  for S N Ss . B r oo ke r et  al . [1]  prese n t e d a  m i ddl eware  pl at form  fo r d e v e l opi n g  s o ci al   net w or ki n g  a p pl i cat i ons s p ec i f i cal l y  for sm art p ho ne  devi ce s.  W i t h   th eir  m i d d l ew ar e,  n o t   on ly can  a sm ar tp hone r e qu est a  serv ice bu t it can   also  ho st a  serv ice w ith th help  of  surrogate cl ouds. One  of the  features  for e nha ncing  pe rform a nce is a n  ada p tive  heartbeat m echanism   that   dynam i cally controls the  fre quency of  heart b eat  m e ssage s between a  sm artphone a nd a  surrogate acc ordi ng to  th e serv ice con t ex t. M o b i Cliq u e   [2 ] is  m o b ile so ci al  net w o r ki n g  m i ddl eware t h at   di rect l y  di ssem i nat e s   cont e n t  am ong  op po rt u n i s t i cal l y  connect ed  devi ces i n  a d  h o c soci al  net w or ks. T w o di st i n g u i s hi n g  feat ures  of   M obi C l i que a r e t h at  i t  does  not   depe n d  o n  a cent r al i zed  serve r  a nd t h a t  i t  t a kes adva nt age  of t h e s o ci al  net w or k o v erl a y  t o  di ssem i nat e  cont ent  i n  a  peer -t o - pee r  m a nne r. M o bi S o C  [3]  i s  a  m i ddl ewa r e sy st em  t h at  enabl e s  t h de vel o pm ent  of  m obi l e  soci al  com put i ng a p pl i cat i ons a n d  pr o v i d es  a c o m m on pl at fo rm  for   cap turing , m a n a g i ng , and  sh aring  v a ri o u s social states  o f  ph ysical co mm u n ities. To  augmen t th e so cial state ,   Mo b i So C in cor p o r ates  d i scover y  alg o r it h m s  f o r   f i nd ing  prev iou s ly u nkno wn  g e o- so cial  p a tter n s. M o kh tar  et  al. [4] propose d  a  m i ddleware service for pervasi v e so ci al  net w o r ki n g  envi ro nm ent s . W i t h  t h i s  m i ddl ewa r e   service, a use r  can easily fin d  othe r use r s who are so cial ly or physically associ ated and ca n share c o mm on  interests with  them ; this  research foc u se d on social intera ction  am ong users. Ka rki et  al. [5] introduced a  soci al  net w o r k i ng a p pr oach   fo r t h e m obi l e  en vi ro nm ent  usi n g Pee r Ho o d  m i ddl eware .  Peer Ho o d  [ 6 ]  i s  a  net w or k m a nagem e nt   m i ddl eware m o d u l e  t h at  p r o v i d es  a  com m uni cat i on en vi r o nm ent   fo r m obi l e  dev i ces t o   comm unicate  with each ot he r directly , without any cent r alized serve r The supported functionalities include   device a n d se rvice disc overy, service  sh aring ,  con n ection  estab lish m en t, data tran sm issio n ,  activ e m o n ito ri n g   of a  device, and seam less connectivity.  In sum m ary ,   exi s t i ng SN m i ddl ew ar e  app r o a c h es  fo cu s   ma in ly  on s u pporting their s p ecific e n d- user services  suc h  a s  loc a tion se rvices and se ar ch es fo r fr iend s.  H o w e v e r,  th ey o v er look  co mm o n   co mm u n i catio n  serv ices, ev en  thou gh  m a n y  SNS ap p licatio n s  hav e  dup licate an d sim i la r fun c tio n a lities.      3.   CO MM U N IC ATIO N MID D LEWA R E ( C M )   Ou r com m uni cat i on m i ddl eware (C M )  i s  de si gne d t o  s u p p o rt  b o t h  sy nch r o n ous a nd as y n ch ro n o u s   in teractio ns  o f  u s ers, esp ecially w ith in  SNS app licatio n s Th e m a in  ro le  of CM in an  SNS is to supp ort an  easy and efficient way  of  developing   a n  SNS  application with high  c ont ent accessibility. As m i ddleware tha t   i s  l o cat ed l o gi cal l y  bel o w  t h e appl i cat i on l a y e r, C M  pr ovi des a  devel ope r wi t h  AP Is f o r vari ous   comm unication se rvices  suc h  as c o mm unica tion a r chit ecture, user m a nage ment,  and  ev ent tran sm issio n .   We cl assi fy  C M ’s i n t e rnal  cl asses i n t o  t h re e m odul es:  a c ont rol l e r  m odu l e , a m odel  m o d u l e ,  an d   a   no rm al   m odul e. The c o nt r o l l e r m odul e co n t ai ns cl asses t h at  co nt r o l  an d u p d at e i n t e r n al  val u es. T h m odel   m odul e con s i s t s  of cl asses t h at   m a i n t a i n  t h e gl o b al  i n f o rm at i on o f  C M The  no rm al   mod u l e  co nsi s t s   of t h rem a i n i ng cl as ses, t h ose  t h at   bel o ng  t o  nei t h er t h e  c ont r o l l e r m odul e  n o r   t h e m odel  m odul e. Fi g u re  1  s h o w s   the m a in classes in eac h m o dule.  The  role  of  each class is  de scribe d in detai l  in [7].  To  pr ovi de  pl at form  i nde pe nde nce,  C M  was  devel ope d wi t h  Java  u s i ng t h e Ecl i p se Int e grat e d   Devel opm ent  En vi ro nm ent  (IDE ) ;  t hus , w h en com p i l e d i n t o  Java by t eco de, C M  can r u n o n  any  Java  vi rt ual   machine (J VM on a  variety  of  platform s, such as   W i ndows ,  Linux, a n d M ac OS.      4.   CM  C O N F IG UR ATIO N   We assum e  t h at  a devel o per  want s t o   devel op cl i e nt  an d s e rve r  ap pl i cat i ons  usi n g C M .  In o r de r t o   u s e CM, an  app licatio n   n eed s to  im p o r t th CM lib rary  fil e  and  th e Jav a  d a tab a se connectiv ity (JDBC) file,  wh ich  are prov id ed  as Jav a  arch i v e (JAR ) files. In  ad d itio n, con f iguratio n  files  are also  n e ed ed, wh ich  are  p r ov id ed  with   th e CM JAR fi le. Th es e co nfi g uration  files  m u st ex ist in  t h e curren t  wo rk ing  d i recto r o f  the  appl i cat i o n un der   de vel o pm ent .      Evaluation Warning : The document was created with Spire.PDF for Python.
                        I S SN 2 088 -87 08  IJEC E V o l .  5, No . 3,  J u ne 2 0 1 5   :    58 6 – 5 9 8   58 8     Fi gu re  1.  C o m m uni cat i on m i ddl e w are  (C M )  arc h i t ect ure       After t h e c o nfiguration  files have  bee n   placed in  t h e a p propriate dire ctory,  the  ne xt step is to  co nfigu r e th e defau lt  v a lu es with in  th e files.  A serv er  app licatio n  m u st set th e CM  serv er con f i g uration   files,  t h e m a i n  one   bei n g t h c m -s erver.conf   file. Th is is a sim p le tex t   file and  can   b e  ed ited   b y  an y tex t   ed ito r.  Because m o st  configuration fields ha ve  alre ady  been se t to de fault  values , the  only  thing the  de veloper  needs  to  do  is t o  set t h e ad dress  of t h d e fau lt server. CM  can  con f i g ure m u ltip l e  serv ers, co n s istin g   o f  t h d e fau lt  serv er and  additio n a l serv ers; th d e fau lt serv er is th e   one  to  whic h all cli e nts m u st alwa ys connect. T h us, a  serve r  a ppl i cat i on  usi n g C M   can be t h defa ul t  serve r   or a n y  of t h e a d di t i onal  se rve r s;  i n  t h e case  of  si ngl e- serv er system , th e serv er ap p l icatio n  is th e defau lt serv er.  In  th is p a p e r,  we will assu m e  a sing le serv er.    In th serv er con f i g uration file, th d e vel ope r ca n se t  ot he r c o m m uni cat i o n- rel a t e pol i c i e s   su ppo rted   b y  th e CM as well; th d e tails are  g i v e n   b e low.    SY S_ TYPE : app licatio n  typ e . A serv er app licatio n   m u st set th is field  as “SERVER”,  an d  a clien t  as  “CLIENT” in th e clien t -serv e r m o d e l.    COMM_ARC H : comm unication arc h itecture. This  field de si gnates the communication a r chitecture of a n   appl i cat i o n usi ng C M . P o ssi b l e val u es are “ C M _ C S ” f o r t h e cl i e nt -se r ve r m odel  and “ C M _ PS” f o r t h e   h ybrid  m o d e l, t h e latter  o f  wh i c h   u s es m u lticast co mm u n i catio n  in add ition to  th e clien t -serv e r m o d e l.    LO GIN _SC HE ME : u s er au then ticatio n   p o l i c y. If th v a l u e is 0   (false), i t   m ean s th at th e serv er  will n o t   authe n ticate a user  whe n  it re ceives a logi n reque st, an d the  serve r  CM will alwa ys accept the request. If  th e v a l u e is  1   (tru e), th e serv er will co ndu ct th u s er au t h en t i catio n  pro cess.      SE SS ION _ SC HEME : m u lti- sessio n   po licy.  W ith  th is  field ,  th d e v e l o p e r can  sp ecify wh et h e r t h ap p lication  will u s e o n e  sessi o n   o r  m u ltip le  sessio n s If the field  v a lu e is 0 ,  CM will n o t u s e m u lt ip le  sessio n s bu t on ly a sin g l defau lt session ;  in  th is case,  wh en  a  u s er l o g s  in  to  a  serv er,  h e  or she  au to m a tical ly  j o i n s th is sessio n  an d  its  d e fau lt group If th e v a lu e is  1 ,  th serv er  ap p lication  can  co nfigu r e m u lt ip le session so  th at a user can  select  o n e  of  th em  to  j o i n   DOWN L OA D _ SCHE ME : tran sm issio n  po licy o f  SNS con t en t. Th is field  sp ecifies  ho w m u ch  SNS  conte n t a se rver will tra n sm it to a client.  If the  va lue is  0, CM adopts a  fi xe am ount of SNS  c onte n t,  according to the value  of t h DO WNLOAD_ N U M  fi el d. I f  t h e val u e i s  1, C M  uses a dy nam i do w n l o a d i n g s c hem e  [8] .     DB _U SE :  dat a base ( D B )   usa g e fl a g . T h i s  fi el d set s  w h et her a server application uses C M ’s internal DB.  If t h v a lu e is  0 ,  t h e ap p licatio n will no u s e th e CM DB . If th v a lue is  1 ,  t h e ap p licatio n will u s e the  CM DB, and  t h fo llowing ad d ition a DB i n fo rm atio n  m u st  b e   supp lied :  DB h o s t, u s er n a m e p a ssword po rt   num ber, a n d  DB   nam e   UDP _P OR T : defau lt po rt num b e r o f  th e serv er ap p licati o n .  Usi n g C M , a ppl i cat i o ns can  send a m e ssage  with  a UDP con n ection .   Th is  field  assign s the p o rt nu m b er of the s e rver a ppli cation  as th e d e fau lt UDP  co nn ection ,   which  is  o p e n   when  th e serv er C M  starts.    FILE _PA T H d e fau lt p a th for file tran sfers. CM refers to   th is p a th   wh en p e rform i n g  file tran sf ers .  If  a   file is req u e sted , th e serv er or clien t  searches for th e f ile in  th is file p a th; if a clien t  rec e iv es a file, CM   Evaluation Warning : The document was created with Spire.PDF for Python.
IJECE   ISS N 2088-8708      Application-le vel Comm unic a tion Se rvices  for Developme nt  of  Social Ne tworking Sy stems   (Min gyu Li m )   58 9 stores the file in this file path.  If a serve r  receives a file, CM stores  the  file in a sub-directory of the  d e fau lt p a t h ; the sub - d i rect o r y  is set to  t h n a me o f  t h e client th at sen t  t h file.     SE SS ION _ N U M :  num ber of  sessi on s. T h e val u e m u st  be great er t h an  or  equal  t o  1  bec a use C M  uses  at   least one  sessi on.    SE SS ION _ F I L E # :  nam e  of s e ssi on c o nfi g u r at i on  fi l e . “# ” i s   an  in teger (starting  with 1 )  t h at acts t o   di ffe re nt i a t e  am ong sessi o n s .  In a ses s i o n con f i g urat i o f i l e , t h e devel o per set s   gr ou p  i n fo rm at i on for   th at session , such  as group   n a mes an d m u ltic ast add r esses.    SE SS ION _ N A ME# : sessi o n   n a m e . “# ” is an  in teg e r (startin g   with  1) that acts to  d i fferen tiate am o ng  sessions. Beca use a  session  na m e  in CM is a n   id en tifier,  a un iqu e  n a m e   mu st b e   assi g n e d.  Lik e wise, a cli e n t  app licatio m u st set a C M  clien t  co n f i g uration  file ( cm-clien t .con f ). Un lik e th C M  server co nfi g u r at i on  fi l e , t h e C M  cl i e nt  con f i g urat i o n fi l e  does  no t  have m a ny  f i el ds. The de v e l o p e r   needs to speci fy syste m  type, defa u lt  serv er  i n fo rm atio n ,  UDP po rt nu m b er,  and   file p a th in fo rm atio n .       5.   APPLI CATI O N I N TEG R A TIO N   Whe n  t h dev e l ope r has  fi ni she d  set t i ng t h e C M  con f i g urat i o n fi l e s,  he o r  she i s  n o ready  t o   d e v e l o p clien t   an d serv er applicatio n s  using CM. In  order  to  in itialize and  start CM,  both  th e serv er  an d   th client applications  nee d  to declare an insta n ce of  the CM stub class and set a CM event ha ndler object.    Fi gu re 2 s h ow s sam p l e  code fo r a ser v er a p pl i cat i on. C ode  fo r a cl i e nt  i s  nearl y  i d e n t i cal ;  t h e onl y  di ff erenc e   is that it declares the i n stance   of the CM c lie nt stub class  instead  of t h e se rver stub.          Fi gu re  2.  Ser v e r  a ppl i cat i o n  c ode       The re gistere d  event  handler i s  called by CM whe n ev er it receives a CM event  s o  that an  application  can  be  not i f i e d  of  eve n t  rec e p t i on. T h de vel ope r s h oul de fi ne a n  e v ent   h a ndl e r  cl ass t h at  i n cl ude s an   even t   pr ocess c o de.  Fi gu re  3 sh o w s sam p l e  code fo r t h e se rv er ev en h a nd ler. A clien t  sh ou ld   d e fi n e  th e ev ent   han d l e r  i n  t h e s a m e   m a nner.   Evaluation Warning : The document was created with Spire.PDF for Python.
                        I S SN 2 088 -87 08  IJEC E V o l .  5, No . 3,  J u ne 2 0 1 5   :    58 6 – 5 9 8   59 0     Fi gu re  3.  Ser v e r  e v ent   ha ndl e r  co de       On ce t h e CM is in itialized  an d  starts to   run ,  an   app licatio n can  call CM APIs prov id ed th roug h  t h stub class.      6.   PARTI C IP A T ION  I N  C M  NETWO R K   A CM clien t   mu st lo g  in  to  the d e fau lt serv er in  o r d e r to  in teract with  o t h e r CM n o d e s. Fo r th e logi p r o cess, th e C M  clien t  stub   prov id es th login C M  m e t hod.   Thi s  m e t hod  t a kes t w o  pa ram e t e rs:  use r   nam e  an pass wo rd Wh en a cl i e nt  cal ls t h i s   m e t hod,  t h e cl i e nt  C M   sen d s a l ogi r e que st  t o  t h e d e faul t  ser v er.  Whe n   the server CM receives the l ogi n re que st, it authenticates  the requestin g use r  accordi ng to t h e CM login  s c h e me  s p e c i f i e d  in th e CM se r v er  co nfiguratio n   file. If t h e serv er CM  LO GI N_S C HEME  val u e i s   0,  i t  do es  not aut h enticat e users, i n stead accepting  e v ery login re quest ; in this case, th e server a nd c lient applications do  not  n eed t o   d o  any t hi n g  f u rt her a f t e r t h e l ogi n re que st . I f  t h e ser v er C M   LOGIN_SC HEME   val u e i s  1, t h serv er app licatio n  is respon si b l e for au th en t i catin g  th e requ esting  u s er wi th  its o w n  au t h en ticatio n  po licy. To   th is en d, th e serv er n e ed s to  cap ture th e lo gin  requ es t ev en t in  th e ev en t  h a nd ler,  a u the n ticate the user, a nd  n o tify th e user  o f  th resu lt.  A si m p le au th en t i catio n  t echni q u e i s  t o  use t h e  C M  DB   m a nager ,  w h i c h p r o v i d es  an aut h entication m e thod. T o  check  wh ethe r the login  re quest is succes s f ul , t h e client  needs to ca pture the  reply eve n t. If  the res u lt field of the  re ply event is 1,  the l o gin re quest has  success f ully com p leted; otherwise ,   t h e l o gi p r oce ss has  fai l e d .   Aft e r  t h e l ogi n  pr oces has c o m p l e t e d, a cl i e nt  m u st  joi n  a  sessi on  a n d  a  g r o u p  t o  fi ni s h   ent e ri n g  t h CM network.  The sessi on  join proces s is  diffe re nt  according to  whet her the se rve r   has a d opted a  single  sessio n  or m u ltip le session s i n  its co nfigu r atio n   file. If  th ere is a  sing le sessio n , th e clien t  CM au t o m a tically   req u est s  t o   joi n  t h e  sessi on  a s  so o n  as t h e l ogi req u est   fi ni shes;  t h u s , t h e cl i e nt  ap pl i cat i on  need   do   not hi n g   ex p licitly fo jo in ing  a session .   If th ere are  m u l tip le sessio n s  av ailab l e, th e clien t  n e eds to  req u e st session  in fo r m atio n ,  ch oo se on e sessio n ,  and   r e q u e st to   j o i n  th at  sessio n  thr ough  th e CM clien t  stub W h en   a clien t   j o i n s a session , it au to m a tical l y  p r o ceed s  to jo in  t h d e fau lt  g r ou p of th at  sessio n     7.   CM  C O M M U NIC A TIO N   S E RVI CES   Fo r bu ild ing   an  SNS app licatio n ,  CM  prov id es  v a rious co mm u n i catio n-related   fun c tio n a lities,  i n cl udi ng e v e n t   m a nagem e nt , user m a nagem e nt , f r i e n d  m a n a gem e nt , SNS  cont e n t  m a nagem e nt , chat , an d fi l e   tran sfer. In  t h is sectio n,  we  d e scrib e  t h ro les of  these  servic es and  how an  application ca n use  them   Evaluation Warning : The document was created with Spire.PDF for Python.
IJECE   ISS N 2088-8708      Application-le vel Comm unic a tion Se rvices  for Developme nt  of  Social Ne tworking Sy stems   (Min gyu Li m )   59 1 7. 1.   E v e n t M a n age ment   As C M   ha ndl e s  eve r y  o u t g oi ng  an d i n com i ng  m e ssage as  a t y pe o f  C M   event ,  an  a ppl i cat i on  nee d to create an appropriate eve n t in orde r to se nd a  m e ssage. F o r sim p licity,  CMDummyEve nt  i s  one  o f  t h e  e v e n t   cl asses sup p o rt ed by  C M  and  has onl y  o n e st ri ng fi el d. T h i s  event  i s  us eful  w h en t h devel ope r wi s h es t o   d e sign  a sim p l e  ev en t th at con t ain s  t h e sem a n tic in  a string   v a riab le. To   su ppo rt t h e m o re flex ib le  format o f  a  user-define d  e v ent, CM als o  provi des the CM event  class  CMUser Event Using   th is ev en t class, th devel ope r can  defi ne an eve n t  fi el d wi t h  a fi el d dat a  t y pe, a fi el d nam e , and i t s  val u e. N o rm al dat a  t y pes such   as in t, lon g , float, d oub le, ch ar, St ri ng, and  byte can be us e d  in eac h eve n t  field. A c r eate d  eve n t field c a n be   adde d to t h e instance  of t h e   CMUserEve n t  class. A  CM UserEve n t  ev en t th at h a s its o w n  ev en t fi eld s  is  i d ent i f i e by  a  st ri ng i d e n t i f i e r, t h nam e  of  whi c h i s  al so  d e fi ne d by  t h e d e vel o per .  T h req u i r e d  m e t hods t o   set and   g e t th id en tifier and  ev en field s  are  d e scri b e d in   Tab l e A1   of  App e nd ix A.  The  setS tring I D  m e t hod i s  us ed t o  de fi ne t h e ID o f  a user - d efi n ed e v ent .   The de vel o pe r sho u l d  n o t e   th at th d a ta ty p e   o f  an ID  is  Str i ng  rath er than  i n t.  A lth ough  the  p r e- d e f i ned  CM ev en ts  u s e an   ID   o f  typ e  i n t,  th CMUser Ev ent  class use s  the Stri ng type   because it offe rs  m o re rea d abilit y for a  use r -de f ine d  e v ent. The   ID  of a  use r  e v ent can be  ret r ieved by calling the  g e tS tringID  m e t hod.   To  set an  ev ent field  in  a u s er ev en t, th set E ven tField  m e t h o d  i s  use d T h i s  m e t hod re q u i r es t h ree   param e t e rs:  dat a  t y pe, fi el d nam e , and fi el val u e. F o r t h e dat a  t y pe, C M  pr o v i d es si pr im it i v e t y pes that  are   nam e d as co nst a nt  val u es,  sh o w n  i n   Tabl 1.   The fi el dat a  t y pe and t h fi el d nam e  par a m e t e rs are re qui red  fo r i d e n t i f y i ng t h e di ffe rent  e v ent   fields in a  user  event. T h e last  param e t e r i s  t h e fi el val u e .  T h i s  val u e m u st  al way s  be  gi v e n as  St ri n g  t y p e , n o   matter wh ich   data typ e  is u s ed  fo r t h e ev en field .  In   o r d e r to  retriev e  a  field  v a l u e, t h g e tEven tField  meth od  can be cal l e d.  Thi s  m e t hod re qui res t h e fi el d  dat a  t y pe  and  t h e fi el d nam e   as param e t e rs and  ret u rns t h e  val u e   of t h e c o rrespondi ng eve n t fie l d. Because the  return  va lue is  String type, t h e de veloper s h oul d tra n sform it to  th e orig i n al d a t a  typ e  if  n e ed ed     Tabl e 1. Fi el d Dat a   Ty pes   o f  C M UserE v e n t  Eve n t   Field data t y pe  M a tching Java data ty pe  CMIn f o .CM_ INT  in CMIn f o .CM_ LON G  lo n g   CM I n fo. C M _ FL OA T floa t   CM I n fo. C M _ DOUBL E  double   CMInfo.CM_CHAR char  CMInfo.CM_STR  String      The  setEve ntB y tesField  m e th o d  is used to   set an  ev en t fi eld   th at is an   arb itrary b y te  stream . Fo exam pl e, by t e s rea d  f r om  a fi l e  can  be a n  e v ent   fi el d.  Thi s  m e t hod  r e qui res t h ree  param e t e rs. T h e fi rst   param e ter is  the field nam e , identifying the event fiel d of t h e by t e  st r e am . The seco nd  param e t e r is t h n u m b e r of b y tes in  th e b y te s t ream . Th e last  p a ram e ter is  a  b y te array th at co n t ain s  th e bytestrea m  v a lu e. Th by t e  array  can  be ret r i e ved  by  t h getEventB ytesField   m e t hod . R e q u i r i n onl y  t h e fi el nam e  param e t e r, t h i s   m e t hod  ret u r n s  t h by t e st ream  val u e  as a  by t e  array .   The exam ple in Figure  4 shows how a CM client creat es a sa m p le user event.  T h e ID of the eve n t is   “testID”, an d two  ev en t field s  with  d i fferen t   d a ta typ e are  set to the eve n t .  The c lient se nds  the cre a ted event   to  th d e fau lt serv er.          Fi gu re  4.  Exa m pl e of C M Us erEve n t  c r eat i o n       A C M  ser v e r   o r  cl i e nt  a ppl i c a t i on ca n se nd  a n  e v ent  i n  a n y   one  o f  t h ree t r a n sm i ssi on m odes:  one -t o - one one -to-m a ny,  or one-t o -a ll transm ission. In  one-to- one  transm ission,  there is  only  one receive r. In  one - to-m any  m ode, a sender can  designate sessi on m e m b ers or  group m e m b e r s as t h e reci p i en ts of th e ev en t.  In  Evaluation Warning : The document was created with Spire.PDF for Python.
                        I S SN 2 088 -87 08  IJEC E V o l .  5, No . 3,  J u ne 2 0 1 5   :    58 6 – 5 9 8   59 2 o n e -to-all m o d e , th e ev en t is  sen t  to all log g ed -i n   u s ers.   Such tra n sm issions a r realized by t h ree  m e th ods   of  th e CM stub : t h se nd ca s t  (o mu ltica s t ),  a n d   b r oa dca s t  m e t hods .   To re ceive a  user-defi n ed event, a CM a pplication can ca pture a user e v ent  of t h C M UserEve n t   type, like othe r CM events.  The exam ple in Figure  5 s h ow s how  th e d e f a u lt serv er   ca ptures the user event   sen t   b y  th p r ev iou s  ex am p l e an d prin ts  ou t th e field values  in  the server  event  ha ndler.          Figure  5. Receiving a CM Use r Eve n t e v ent       7. 2.   Use r  Ma na gemen t   The  user m a na gem e nt  funct i o n of C M  i n cl u d e re gi st rat i o n,  dere gi st rat i o n,  and  use r  sea r c h . B eca use  u s er pro f ile info rm atio n  shou ld   b e  st o r ed  in  a DB, th d e v e lo p e r m u st set th e serv er co nfig uratio n file t o   u s th e CM DB (via  D B _U SE  an d ot her  rel e va n t  fi el ds) i n   or d e r t o  u s e t h e u s er m a nagem e nt  su pp o r t  fu n c t i ons .   User m a nagem e nt  AP Is are  p r o v i d e d  by  t h e  C M  cl i e nt  st u b , as s h o w n i n  Fi gu re 6.  A C M  cl i e nt  can send a   user m a nagem e nt  req u est  t o  t h e de faul t  ser v er, an d t h d e fau lt serv er th en  pro cesses th e requ est u s ing  th e CM  DB. Th d e fault serv er  send th e resu lt o f  the requ est as  a  CM event that  can be cap t u re d by t h e client  event   han d l e r ,  as  be f o re .           Fi gu re  6.  M e t h ods  f o r  u s er  m a nagem e nt       A use r  ca n be  regi st ere d  t o  C M  by  t h regis t erUser  m e t hod o f  t h e C M  cl i e nt  st ub . I f  a  C M  cl i e nt  i s   con n ect ed  t o   t h e de faul t  se rve r , i t  can c a l l  t h i s   m e t hod. C M  u s es t h e re gi st ere d   user i n f o rm at ion t o   authe n ticate a  user  whe n  that  user  log s  in  to  th e d e fau lt serv er. Th regi sterUser  m e th o d  requ ires  o n ly two  param e t e rs:  user nam e  ( strName ) a nd  pass w o r d  ( strP assw d ). If the user  na m e  alr ead y ex ists in  th e C M  DB,  the registration fails;  if the user nam e   is uniquely sp ecifie d , the re gistration succee ds . The succes s status of  th e reg i stratio n requ est is assig n e d  to  t h e ret u rn code  of t h e reply session event  RE GISTER_USER _A CK . If   the re quest is  success f ul, the  re ply ev e n t also c o ntains the  re gistration tim e at the server. T h details of the   REGISTER _ USER _ACK  e v e n t  are  sh o w n  i n  Tabl A 2   of  A ppe n d i x   A.   A use r  can ca ncel  hi s o r  he r  regi st rat i o n f r o m  C M  by  t h deregi st er Use r   m e t hod  of t h e C M  cl i e nt  stub. If a client is connected  to  th d e fau lt serv er, it can  call th is  m e t hod .   When  re que st ed, C M   rem oves t h e   regi st ere d   use r  i n f o rm at i on f r om  t h e C M  DB . Li ke t h e   registerUse r  m e t hod,   t h deregisterUse r  m e t hod   requ ires on ly two p a ram e ters: a u s er  n a m e  ( strName ) a n d   pass wo rd  ( strP asswd ).  I f  t h e   gi ve user  na m e  wi t h   the correct pas s word exists  i n  t h e C M  DB ,  t h e dere gi st ra t i on re que st  i s  successf ul ;  ot her w i s e, t h e re que st   fai l s . T h e s u cc ess st at us  o f  t h e de regi st rat i o req u est  i s  as s i gne d t o  t h e  ret u r n  c o de  of t h e  re pl y  sessi o n   event   DERE GIST ER _USER _ ACK ,  descri bed   i n  T a bl A 3  o f  Ap pen d i x   A .   Evaluation Warning : The document was created with Spire.PDF for Python.
IJECE   ISS N 2088-8708      Application-le vel Comm unic a tion Se rvices  for Developme nt  of  Social Ne tworking Sy stems   (Min gyu Li m )   59 3 A use r  ca n se arch  fo r a not h e r use r   by  t h e   fin d R eg istered U ser  m e t hod  of t h e C M  cl i e nt  st u b . I f  a  cl i e nt  i s  co nne ct ed t o  t h def a ul t  ser v er , i t   can cal l  t h i s   m e t hod.   Whe n  req u est e d, C M  pr o v i d es t h e basi c   pr ofi l e   of  t h e t a rget   use r , i n cl udi ng  s u ch  i n f o rm at i on as  na m e  and  re gi st r a t i on t i m e. The  fin d R eg istered U ser   m e t hod  req u i r es o n l y  t h e us er nam e  para m e t e r. If t h gi ve n u s er  na m e  exi s t s  i n  t h e C M  DB , t h e searc h   requ est is su ccessfu l;  o t h e rwi s e, th e re quest  fails. The s u cc ess status of the  user  searc h  reque st is assigned t o   th e r e t u rn  code of  th e r e p l y session  ev en FIN D _R EGISTERE D_USER _ACK desc ri b e d i n  Ta bl e A 4   o f   Ap pe ndi x A.     7. 3.   Fri e nd  M a n age ment   In  an  SNS ap plicatio n ,  it is co mm o n  to  supp ort th e m a nag e m e nt  of f r i e n d s f o r a  use r C M   m a kes i t   easy for a client to  ad d, d e lete, and  g e frien d in fo rm atio n .  In  ord e r to   u s e t h is serv ice, th e d e v e l o p e n e ed s to  sp ecif y  u s o f  th e CM D B , as in  th e u s er  m a n a g e m e n t   case. Figu r e   7 sh ow s a synop sis of  th e r e l e v a n t   m e t hods  o f  t h e  C M  cl i e nt  st u b .           Fi gu re  7.  M e t h ods  f o r  f r i e n d   m a nagem e nt       A clien t  can  call th addN ew Fri end  m e t hod  t o  add a ne w f r i e n d . A c lient can add a user  as its friend  only if the user nam e  has already been  re gist ered to CM. If  the friend is a re gistered  user, the serve r  adds  it  to  the frie nd ta ble of the CM DB as a friend of the re que s ting  u s er; o t h e rwise, th e req u e st fails. In  eith er  case,  the serve r  sends the reply event  ADD_ NEW_ FRIEND_ A CK  with  th e resu lt co d e  to  th e requ esting   clien t  to   in fo rm  i t  o f  th e req u e st resu lt. A clien t  can  d e lete a frien d  by call i n g  th remove Friend  meth od , and  th e resu lt   of  t h re ques t REM OVE _ FRIEN D_ACK , is se nt to the  requesting client. T h event  fields  of  bot h   ADD_ NEW_ FRIEND_ A CK  and  R E MOVE _FR I END_AC K  are identica l  and are  desc ribe d in Ta ble A5  of  Ap pe ndi x A.   Di ffe re nt  SNS  appl i cat i o ns us e t h friend concept in diffe r e n t ways. In  some applications, a user can  add a not her  u s er t o  hi s o r   her f r i e n d  l i s t  wi t h o u t  nee d i ng t h e a g ree m ent  of t h e t a rget  us er.  In  ot her   applications, a  user can a dd  a friend  only if the othe r use r  accepts the fr iend request.  CM supports these  di ffe re nt  p o l i c i e s of  fri e n d   m a nagem e nt  by  p r o v i d i n g   m e t hods  t h at  req u est   di ffe rent   user l i s t s . The   requestFriends List   m e t hod  r e que st s t h e l i s t  of  user s w hom  t h e req u e st i ng  user  ha s ad ded as  fr i e nds ,   rega rdless  of their accepta nc e by the others. The  request FriendRequest ersList   m e th o d  req u e sts th e list o f   users  w h hav e  ad ded  t h re que st i ng  use r   as a f r i e n d   but  w hom  t h e re q u est i n g u s er  h a s n o t  as y e t  a dde d as   friends . T h re que stBiFriends List   m e t hod  re que st s t h e l i s t  of  use r wh h a ve a dde d t h e   req u est i n use r  as a  friend and   who m  th e req u e st in g u s er  h a s ad d e d as  frien ds. To  illu strate, three  d i fferent frien d relation s h i p s   can  be  rep r ese n t e d a s  a  di rect ed  gra p h, s h ow n i n  Fi g u r 8.           Fi gu re 8.   Di f f e r ent  fri e n d   rel a t i ons hi ps       A no de re pre s ent s  a user, an d a di rected edge is a friend relationshi p. In the figure, the r e are three   users ,   A B , and  C . The exist e nce of a direc t ed edge from  user  A  to  u s er  B  m eans  that  A  has add e B  as its  fri en d.  I f  t h e r e  are e dge s i n   bot di rect i o ns  bet w ee n t w no des ,  t h e c o r r esp o ndi ng  us ers  have  ad de d eac h   ot he r,  becom i ng bi l a t e ral  f r i e nds . I f  u s ers  A B , and  C  now  call the above  three m e thods, the res u lt will be as   sho w n i n  Ta bl e 2.     Evaluation Warning : The document was created with Spire.PDF for Python.
                        I S SN 2 088 -87 08  IJEC E V o l .  5, No . 3,  J u ne 2 0 1 5   :    58 6 – 5 9 8   59 4 Tab l 2 .  Resu lts of Callin g Three Friend s-rel a ted  Metho d s   M e thod nam e   A result   B result  C result  requestF r iendsList   B A,C   requestF r iendR equestersList  C N/A B  requestBiFriendsList  B A  N/A       Whe n  the  defa ult serve r  recei ves the re quest  for frie n ds, re que sters,  or  bilateral friends from  a client,  it sen d s  th e co rresp ond ing u s er  list as th RESP O NSE_F R IEND_L IST R E S PO NSE _ FR I E ND_ R EQUE S T ER _L IS T , or  R E SP ON SE _BI _ FR IEN D _ L IS T  ev en t to  t h e requ estin g  clien t The t h ree  eve n ts  have  the  s a m e  even t   fi el ds,  w h i c h  are   descri bed  i n  T a bl A6  o f   A p pen d i x   A.  O n e  o f  t h e   ev en field s  is th frien d list, bu t the m ean in g   of th e list d i ffers accord i n g  to  t h e ev ent ID. Th friend  list  cont ai n s  a m a xi m u m  of 50  user  nam e s. If t h e t o t a l  num ber excee ds 5 0 ,  t h e serve r  wi l l  send t h e e v e n t  m o re  than once.    7 . 4 .    SN S  Co nt en Ma nag e men t   Using t h e SNS content se rvice of CM, a  client ap p licatio can   r e qu est t o   u p l o a d an d dow n l o a d SNS  cont e n t .  F o upl oadi ng  o r  do w n l o a d i n cont e n t ,  a cl i e nt  can cal l  t h requestSN S Content U pl oad  or  requestSN S Content  m e th o d , resp ectiv ely, in  th e CM clien t   stu b . Fi g u r e   9   sh ow s a synopsis o f  th ese m e th od s.  Fo p e rsisten c e of SNS con t ent, th e CM  d e fau lt serv er st ores th up lo ad ed   co n t en t in an SNS con t en t table o f   the CM DB.  There f ore, the  CM serv er  m u st b e  set to   u s e th e CM DB.  To req u est con t en u p lo ad  or  d o wn lo ad , a clien t  m u st lo g  i n  to  th e d e fau lt serv er.          Fi gu re  9.  M e t h ods  f o r  c ont e n t  u p l o a d  a n d  d o w nl oad       A clien t  can  call th req u est S N S C ont e n t U p l oa d  m e t hod t o   upl oad  a m e ssage t o  t h e  de faul t  se rve r .   Thi s  m e t hod  r e qui res si pa ra m e ters. The  first  pa ram e ter,  user , i s  t h e nam e  of  t h e  use r   w h o  u p l o ad s a   m e ssage. The  second param e ter,  mess age , is a tex t   messag e . Th e th ird   param e ter,  n N u m Atta ch ed Files , is th n u m b e r of attach ed  files in  this  m e ssag e ; th i s  p a ram e ter v a lu e m u st b e  th sam e  as th e n u m b e r o f  ele m e n ts in   th e file p a th  list sp ecified  as th e last p a rameter. Th e fou r t h  p a ram e ter,  nRe p l y Of , indicates the ID num ber  (greater tha n   0) of the  co nt en t  t o  w h i c h t h i s   m e ssage re pl i e s;  a val u o f  0   i ndi cat es t h at  t h upl oade d c o nt ent   is origi n al rat h er t h an  a re p l y .  The fi fth  p a ram e ter,  nLev elOfDisclos u re , sp eci fies th e lev e l of d i scl o sure  (Lo D of  t h e  u p l o a d ed  c ont e n t .  C M  al l o ws  f o u r  l e vel s   of  di scl o su re  of   cont e n t :  L o D   op ens  t h e  u p l oade d   cont e n t  t o   pu bl i c  vi ewi n g, L o D 1  al l o ws  o n l y  t hose  user wh have  ad de d t h u p l o a d i n g u s er as a  f r i e nd t o   access the uploaded c o ntent,  LoD 2 a llows  only bilateral friends of the  uploa d ing user t o  access the  uploade cont e n t ,  an Lo D 3 m a kes t h e upl oade d  cont e n t  pri v a t e. The l a st  p a ram e t e r,  fi lePa th List , is th e list o f   attach ed  files. Path  n a m e s o f  attach ed  files sh ou ld  b e   g i v e n  as typ e  ArrayList, and  th e nu m b er o f  array   ele m ents  m u st be the  sam e  as th at specifie d  a s  the  value  of t h n N umAtta ch edFiles  pa ra m e ter.  If the serv er receiv e s a co n t en t up lo ad   request, it st ores the requeste d m e ssage  with the  user  nam e t h e i nde x o f  t h e cont e n t ,  t h e u p l o a d  t i m e , t h e num ber o f  at t achm e nt s, t h e repl y  ID, a nd t h e  l e vel  of di scl o sure If the c o ntent has files attached, the c lien t  t r an sfers th em   sep a rately to  th e serv er. After th e up lo ad  task  h a co m p leted ,  th e serv er send s t h CON T ENT _ UPLOAD_R ESP O NSE  ev en t to  t h requ estin g  clien t  so   th at the  client can c h ec k the  res u lt of t h e re quest. T h e  eve n t fields  of the  CON T EN T_UPL O A D _R ESP O NSE  eve n t are   det a i l e d i n  Tab l e A7  o f   A ppe ndi A.   A cl i e nt  can  r e que st  t o  d o w nl oa d co nt ent   by  cal l i ng t h e   requ est S N S C ont e n t  m e thod . The  first   param e t e r of t h i s  m e t hod,  st rUser , i s  t h nam e  of t h e r e que st i ng  use r . The sec o nd  param e t e r,  strWriter speci fi es a use r  wh o has  upl oa ded c ont e n t .  F o r t h i s   param e ter, t h e cl i e nt  can desi gnat e  ei t h er a speci fi c wri t e r   nam e  or a fri end  gr ou p.  If t h e param e t e r val u e i s  a speci fi c user nam e , t h e cl i e nt  dow nl oad s  onl y  co nt ent  t h at   has bee n  upl oaded by  the specified nam e   and  that  is   acce ssible by  the  reque ster. If the pa ram e ter value is   “CM_MY_FR I END”, the cl ient  d o w n loa d s co ntent t h at was  u p loa d e d   by  the  req u e ster’s  frie n d s .  If  the   p a ram e ter v a lue is “CM_ BI_FRIEND”, th e clien t  d o wn l o ads c onte n t that was uploa d ed by the  re quester’s   b ilateral friends. If t h e p a rameter v a lu e is an e m p t y strin g  (“”), th e clien t   d o e s no t sp ecify a writer n a me, and  it downloa ds a ll content that the requester i s  eligible to access. The last  param e ter,  nOf f set ,  i s  a n  o f f s e t  f r o m   Evaluation Warning : The document was created with Spire.PDF for Python.
I J ECE   I S SN 208 8-8 7 0 8       Application-le vel Comm unic a tion Se rvices  for Developme nt  of  Social Ne tworking Sy stems   (Min gyu Li m )   59 5 t h e begi nni ng  of t h e re q u est e d co nt ent  l i s t ,  speci fy i n g t h at  t h e cl i e nt  want s  t o  do wnl o ad s o m e  nu m b er of  SNS   m e ssages starting  from  the  nOffset -th m o st recent m e ssage. The   nOffset  value m u st be  greater tha n  or equal   to  0.  Wh en th e server receiv e s th d o wn lo ad   request, it first  d e term in es h o w m a n y  SNS m e ss ag es  will b e   sent . Th e n u m b er  of m e ssages i s  deci ded  by  t h DO W N L O AD _S CH EM E  field of the serve r  confi g uration  fi l e . I f  t h i s  fi el d i s  s e t  t o   0,  t h e ser v er  u s es t h fi xe d m a xi m u m  num ber of  m e ssages pe r re q u est ,  acc o r di ng  t o   th e v a lu e of the  DOWNL OA D_N U M  fi el of t h e co n f i g ur at i on fi l e . If  DOWNLOAD_SCHEME  is set  to  1 ,  th serve r  use s  o u dy nam i c d o w n l o a d i n g sc hem e , whi c det e rm i n es t h e num ber o f  d o w n l o a d e d  m e ssages   according t o  the round-tri p  de lay betw een the server a n d the requesting cli e nt. Eac h  SNS  message is the n  se nt   to  th e clien t  as a  CONTENT_ DOWNLOAD  ev en t,  wh ich   can   b e  cap t ured  in th e clien t  ev en t h a nd ler. The  fields o f  the   CONTENT_ DOWNLOAD  e v e n t  are  descri be d i n  Ta bl A8  of  A ppe n d i x   A.  In m o st  cas es, t h e   serv er send s mu ltip le  CONTENT_ DOWNLOAD  e v e n t s , c o r r esp o ndi ng  t o  t h num ber  of   SNS  m e ssages, a n d   th en  it send s t h CONTENT _ DOWN L OA D _ END  ev e n t to   s i g n a l th e  en o f  th e  cur r e n t   d o wn lo ad .   T h is  e v en cont ai n s  a fi el d t h at  gi ves t h e num ber  of  d o w n l o a d e d  m e ssages.  A cl i e n t  can sen d  a not her  d o w n l o a d   req u est   by  u pdat i n g t h e of fset  pa ram e t e r wi t h  t h n u m b er of  p r ev i ousl y  d o w nl o a ded m e ssages .  The  det a i l e event   fields of the  C O NTENT_ DOWNLOAD_EN D  eve n t  are  de scri be d i n  Ta bl e A9  o f  A p pen d i x   A.  If t h e c ont e n t   h a s attach ed   files, th e clien t  sto r es th em sep a rately  in  th e d e fau lt d i rectory th at is sp ecified in  th FILE _PA T H  fi eld  o f  th e clien t  co nfigu r ation  file. Th e clien t  sh ou ld   u s e th e d i rect o r y inform at io n  from th CMFileTra n sferIn f o  classes in order to acc ess th e downl o ade d  files be cause the  CONTENT_DOWNLOAD   event i n cludes  only the   attached file  nam e s.    7.5.   Chat Management  Ano t h e way  clien t s frequ ently in teract wi th  o t h e r clien t s is  v i a ch at.  A clien t  can   sen d  a ch at  messag e  sim p l y  b y  callin g the  chat  m e th o d   o f  th e CM clien t  stub . Th is meth od  tak e s t w o  st ring   p a ram e ters: a  t a rget  an d a t e xt   m e ssage. Us i ng t h e t a r g et  param e t e r of t h chat  m e t h o d , we ca n easi l y  cont r o l  t h e r a nge  of   r ecip i en ts. Th e to p lev e of  the r a n g e  is “/b , wh ich   br o a d c asts th e ch at ev en t t o  all logged - i n   u s er s. The “/s”  v a lu e is  u s ed  if a send er wants to  ch at with o n l y th ose  us ers who are i n  the sam e  current session.  The “/g”   v a lu e lim its th e recip i en ts to th e cu rren gro u p  m e m b ers.   In t h e last cas e there  is only one re ceiver,  whos e   nam e  is designated afte r the  “ / ” char acter as  th e first p a rameter of th c hat  m e t hod   A CM application can recei ve a chatting event by  capturing a pre-defi ned  CM event in the eve n han d l e r ,  i n  t h e sam e   m a nner as ot her e v ent s . The r are two types  of CM c h at events . One  is the   SE SS ION _ TA L K  event  of t h CMSessionEve n t  class; a client can  receive t h is ev e n t if it is logge d  in at least to  th e d e fau lt serv er. Th othe r event is the  USER_TALK  event of  the  CMInterestEve n t  class; a client can  receive this e v ent only if  it joins a  group.  Tables A10 and A11 of  Appendi x A, res p e c tively, descri be the   d e tailed  field in fo rm atio n  fo th ese ev en ts.    7. 6.   Fi l e  T r an sfer  Ma na gem e nt   CM ap p lication s  th at conn ect d i rectly to   e ach  othe r ca excha n ge a  file using t h CM S t u b  class ,   wh ich  is th p a ren t  class of th C M C l i e n t St ub  and   C M Server St u b  classes. For e x a m ple, in client-server  architecture, a  client can pu sh  or pu ll a file to  o r  fro m  a serv er b y  callin g  th p u sh File  or  re que stFile   m e t hods . I n  o r de r t o   use t h e fi l e  t r a n sfe r  ser v i ce, a  C M  ap pl i cat i o n  m u st  set  a di rect ory  t o   be  t h e fi l e   repo sitory.  When  CM is in itialized  b y  an app licatio n ,  t h defau lt d i rectory is co nfigu r ed in  th e con f iguratio file (b y th FILE_P AT H  field ) . If a file is req u e sted , th e serv er or clien t  search es for the file in  th is fil e  p a th;   if a client recei ves a  file, CM  stores t h e file i n  this  file path. If a  server re c e ives a file, C M  stores t h e fi le in a  sub - di rect o r y  of t h e de faul t   pat h ;  t h e s u b- di rect o r y  i s  se t to  th e n a m e   o f  t h e clien t  th at sen t  th file.  An  ap p lication  can ch an g e  th d e fau lt file p a t h   by th setFilePath  m e t hod.    In pull m ode, a CM application requests a file fro m  another rem o te CM  application. For exam ple, a  CM clien t  can requ est t h at a CM server sen d  a file.  file is requ ested b y  th requ estFile  m e t hod.   Th e   requ estFile  m e th od   requ ires two p a ram e ters: th e requ ested file  nam e  and   t h e nam e  of  t h e fi l e  o w ner.  I n   pus h   m ode, on t h e o t her ha n d , a C M  appl i cat i on  can sen d  a fi l e  t o  anot her rem o t e  C M  app licatio n .  A  file is  p u s h e by  t h pu sh File   m e t hod. Li ke  t h requ estFile  m e t hod,  t h pus hFi l e  m e t h od  req u i r es t w o pa ram e t e rs:  the pat h   nam e  of the  fil e  to  be se nt  a n d the  nam e  of the  receive r.      8.   CO NCL USI O N   In t h i s  pa per ,   we ha ve i n t r o d u ced  o u r c o m m uni cat i on m i ddl e w are  (C M ) , wi t h   w h i c h a  devel ope r c a n   easily im ple m ent comm on comm unication services  for SNS  a pplications in a client-se r ve r arc h itecture. T h e   CM confi g urat ion e n ables a n  SNS se rver t o  speci fy  a po licy fo u s er au th en ticatio n, session  and   g r ou p   or ga ni zat i on f o r use r  i n t e ract i ons , an d a  pol i c y  for S N S c o nt ent  d o w nl oa d.  Usi n g t h e C M  APIs , i t  i s  easy  for  Evaluation Warning : The document was created with Spire.PDF for Python.