Jump to content

create ettiğim socket e ulaşmak?


bilcan

Recommended Posts

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;
 
 
Link to comment
Share on other sites

  • 1 year later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...