Merhaba,
aşağıdaki gibi bir websocket create ettikten sonra form un üzerine koyduğum bir button ile bu socket e data basmak istiyorum ama socket bulunamadı hatası alıyorum. Eğer form un Script kısmında yazarsam JS yi socket e daha sonra ulaşabiliyorum ama open eventini ve ilk gelen data yı yakalayamıyorum. UniSession.AddJs de create edilen nesneler global olmuyor mu?
Button1.Onclick
begin
UniSession.AddJS('var socket = new sgcWebSocket(''ws://127.0.0.1:30002'');');
UniSession.AddJS('socket.on(''open'', function(event) { ajaxRequest(FrmMain.window,''Socket_Opened'', []);});');
UniSession.AddJS('socket.on(''close'', function(event) { ajaxRequest(FrmMain.window,''Socket_Closed'', []);});');
UniSession.AddJS('socket.on(''error'', function(event) { ajaxRequest(FrmMain.window,event.message, []); });');
UniSession.AddJS('socket.on(''message'', function(event) { ajaxRequest(FrmMain.window,''Socket_Message''+event.message, []); });');
end;
button2.onclick;
begin
UniSession.AddJs('socket.send('Hello');');
end;