These are chat archives for synrc/n2o

24th
Oct 2016
AlexanderT
@AlexanderKai
Oct 24 2016 07:35
У меня несколько элементов #upload с разными id - как мне понять от какого upload пришел файл?
Andy
@m-2k
Oct 24 2016 12:21
Передавай контейнер в #ftp.meta
Matti Katila
@mudyc
Oct 24 2016 20:43
i tried to send {client,{join_game,[]}} as was an example in book. however, binary_to_term failed with badarg since there was not join_game atom defined.
Andy
@m-2k
Oct 24 2016 20:44
yes
define unknown atoms in code
n2o uses [safe] mode for prevent mem-leaking
Matti Katila
@mudyc
Oct 24 2016 20:57
now I get [info] n2o_client:Client Message: {join_game,[]} but nothing in app logic is handling it. what defined the module that should have the corresponding event function?
ah, log_modules was not including my module
Andy
@m-2k
Oct 24 2016 20:59
event/1 fun clause in ur module
yep
lol
Matti Katila
@mudyc
Oct 24 2016 20:59
so it is working already
:D
Andy
@m-2k
Oct 24 2016 20:59
himself a hundred times it ran
4 years ago :-)
Matti Katila
@mudyc
Oct 24 2016 21:38
is the client message one way, no 'ok' or some other ack is sent in response?
Andy
@m-2k
Oct 24 2016 21:39
wf:send?
Matti Katila
@mudyc
Oct 24 2016 21:46
but you need to do it like event({client, {foo, []}) -> wf:send(bar).
Andy
@m-2k
Oct 24 2016 21:50
what u want
i dont understand
Matti Katila
@mudyc
Oct 24 2016 21:52
i would like the server to respond to event by sending a json data packet back
so that i can handle it easily in js side
#panel{actions="js code"} or #panel{actions=[#jq{}, "code", …]} or
simple wf:wire(["alert('",wf:to_list(Num),"');"]) orwf:wire([#jq{},#bind{}, …])
#api{} trap in api_event/3
Andy
@m-2k
Oct 24 2016 22:00
or generate event manually
-module(lambda_event).

-compile(export_all).
-include_lib("nitro/include/nitro.hrl").

new(Module,Postback,Code) -> #event{postback=Postback,module=?MODULE,delegate=Module,source=Code}.

render_action(#event{postback=P,delegate=D,source=S}) ->
    E=wf_event:new(P,"lambda",D,api_event,S,[]),
    [list_to_binary(["{ (function() { ",E," })(); }"])].
wf:wire(lambda_event:new(?MODULE,#pubsub{render=?MODULE,target=subscription,action=pickup},"sub()")).
Matti Katila
@mudyc
Oct 24 2016 22:03
i don't want nitro currently since I render with pixi
Andy
@m-2k
Oct 24 2016 22:05
hmm
u want send json to browser?
Matti Katila
@mudyc
Oct 24 2016 22:05
yes
Andy
@m-2k
Oct 24 2016 22:06
that on this occasion said guide?
self() ! {client,Data}?
i dont use json, sorry
Matti Katila
@mudyc
Oct 24 2016 22:12
no problem, once I find out how to send data I can format it to look json
Matti Katila
@mudyc
Oct 24 2016 22:19
this is funny. when I say self() ! {server, foo}; it send it to itself, [info] game:Unknown Event: {server,foo}
Andy
@m-2k
Oct 24 2016 22:21
yep
no funny, server messaging
wf:send(Pool,{server,Message})
also
Matti Katila
@mudyc
Oct 24 2016 22:26

Server messages are usually being sent to client originated on the
server by sending info notifications directly to Web Socket process:

WebSocketPid ! {server, Message}

so I need to find out what is the ws process to be able to send the message
Andy
@m-2k
Oct 24 2016 22:29
--> self()
ws process =:= process =:= browser page process
1 process for client
2 processes for 2 clients
Matti Katila
@mudyc
Oct 24 2016 22:31
but i should see something on the browser's console, right?
Andy
@m-2k
Oct 24 2016 22:33
why
what u want
say simply
Matti Katila
@mudyc
Oct 24 2016 22:34
i want server (erlang n2o app) to send data to client (=browser)
to do that I have:
event({client, {join_game}}) ->
wf:info(?MODULE, "join game",[]),
self() ! {client, foo};
I am assuming the client (browser) gets now the data 'foo'.
Andy
@m-2k
Oct 24 2016 22:37
it does not get?
debug=true;
Matti Katila
@mudyc
Oct 24 2016 22:38
hah, it's coming it's coming!
Andy
@m-2k
Oct 24 2016 22:38
yyyeeeeeeepppp
Matti Katila
@mudyc
Oct 24 2016 22:39
@m-2k thanks :)
Andy
@m-2k
Oct 24 2016 22:39
plz
Matti Katila
@mudyc
Oct 24 2016 23:25
maybe @5HT can help with data presentation. client.js cannot read the binary blob, do you have suggestions how to send data? i see bert in n2o.js has $bert.protos which implement this blob reader. so, what is the intended design in here?
Andy
@m-2k
Oct 24 2016 23:29
#bin{} or #tfp{status= <<"relay">>}
define bin fun in js if u want binary
ftp.relay
just simple
ftp includes meta field, bin - raw data without header
try #bin{} / {bin,Data} / {binary,Data}or see manual, i dunno actual methods for now (for last version of n2o)