Maxim Sokhatsky 11 лет назад
Родитель
Сommit
2b70da628e

+ 14 - 4
apps/web/priv/static/doc/svg.js

@@ -25,9 +25,21 @@ function statsRow(start_name,i,games) {
     document.getElementById('Stat-Right').appendChild(element1);
 }
 
+var user_count = 0;
 function handle_web_socket(body) {
 //    console.log(dec(body).value[0][0].value);
     switch (dec(body).value[0][0].value) {
+        case 'roster_item':
+            var id       = dec(body).value[0][1].value;
+            var names    = dec(body).value[0][2].value;
+            var surnames = dec(body).value[0][3].value;
+            addOnlineUser(id,names+" "+surnames+ " "+user_count++,'appendChild');
+            break;
+        case 'roster_end':
+            onlineHover();
+            mouseWheelHandler({'detail':5,'wheelDelta':5});
+            onlineHoverOut();
+            break;
         case 'stats_event':
             document.getElementById('Player-Statistics').style.display = '';
             var games    = dec(body).value[0][2];
@@ -473,17 +485,15 @@ chatMessage("1","Maxim2","Joe:\nHello There!".encodeHTML());
 chatMessage("2","Maxim2","Alice:\nYou got new Design. Eh?".encodeHTML());
 chatMessage("3","Maxim","Maxim So:\nThis was made with pure SVG".encodeHTML());
 
-
+/*
 for (var i=0;i<5;i++) {
 addOnlineUser("Maxim1"+i,"Maxim Sokhatsky",'appendChild');
 addOnlineUser("Maxim2"+i,"Sinan Ustel",'appendChild');
 addOnlineUser("Maxim3"+i,"Ahmet Tez",'appendChild');
 addOnlineUser("Maxim4"+i,"Alice Cooper",'appendChild');
 }
+*/
 
 barHover();
 mouseWheelHandler({'detail':-100000,'wheelDelta':-100000});
 barHoverOut();
-onlineHover();
-mouseWheelHandler({'detail':5,'wheelDelta':5});
-onlineHoverOut();

+ 1 - 0
apps/web/priv/static/doc/synrc.css

@@ -18,6 +18,7 @@
     B           { font-size:14pt; background-color: lightblue; padding: 2px; }
     H2 B        { font-size:16pt; background-color: lightblue; padding: 5px; margin-top: 20px; margin-bottom: 20px;}
     LI          { font-size:14pt; }
+
     button { display: none; visibility:hidden;}
     label  { display: none; visibility:hidden;}
     input  { display: none; visibility:hidden;}

+ 10 - 0
apps/web/src/okey.erl

@@ -51,6 +51,7 @@ user() ->
                         _ -> new_user() end;
                 _ -> new_user() end,
             wf:user(X),
+            send_roster(),
             X;
         U-> U end.
 
@@ -89,6 +90,14 @@ tash(C,V) -> {wf:to_binary([wf:to_list(C)," ",wf:to_list(V)]), {C, V}}.
 
 main() -> #dtl{file="index", bindings=[{title,<<"N2O">>},{body,body()}]}.
 
+send_roster() ->
+    X = [ send_roster_item(User) || User=#user{tokens=Tokens} <- kvs:all(user), Tokens /= [], Tokens /= undefined],
+    self() ! {server,{roster_end}},
+    wf:info(?MODULE,"Users: ~p",[length(X)]).
+
+send_roster_item(User) ->
+    self() ! {server,{roster_item,User#user.id,User#user.names,User#user.surnames}}.
+
 body() ->
     wf:wire(#api{name=plusLogin, tag=plus}),
   [ #panel    { id = history },
@@ -127,6 +136,7 @@ event(init) ->
     wf:update(games_ids,#dropdown{id = games_ids, value = ?GAMEID, options = 
       [#option{label = wf:to_list(GameId), value = wf:to_list(GameId)} || GameId <- GamesIds]}),
 
+    send_roster(),
     event(attach),
     event(join);
 

+ 1 - 0
apps/web/src/protocol.erl

@@ -19,3 +19,4 @@ reveal(GameId, Color, Value, Hand) ->
         [{discarded, tuple(atom("OkeyPiece"), Color, Value)},{hand, Hand}])))).
 i_saw_okey(GameId) -> ws:send(enc(tuple(atom('client'),tuple(atom("game_action"),GameId,atom("okey_i_saw_okey"),[])))).
 i_have_8_tashes(GameId) -> ws:send(enc(tuple(atom('client'),tuple(atom("game_action"),GameId,atom("okey_i_have_8_tashes"),[])))).
+

+ 1 - 1
rels/web/files/sys.config

@@ -6,7 +6,7 @@
         {transition_port,8080},
         {log_modules,logallow},
         {session,js_session},
-        {pickler,n2o_pickle}]},
+        {pickler,n2o_secret}]},
  {server, [{log_modules,logallow}]},
  {face,[
     {http_address, "http://skyline.synrc.com"},