bilcan Posted December 26, 2016 Share Posted December 26, 2016 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 More sharing options...
Hayri ASLAN Posted December 26, 2016 Share Posted December 26, 2016 Merhaba UniSession.AddJS('var socket = new sgcWebSocket(''ws://127.0.0.1:30002'');'); Aşağıdaki gibi değiştirin UniSession.AddJS('socket = new sgcWebSocket(''ws://127.0.0.1:30002'');'); Link to comment Share on other sites More sharing options...
bilcan Posted December 27, 2016 Author Share Posted December 27, 2016 Çok teşekkürler. Bu arada session da create ettiğim bu socket kullanıcı sayfayı kapatana kadar aktif kalacak değil mi? Ya da benim açık tutuğum sürece. Link to comment Share on other sites More sharing options...
Hayri ASLAN Posted December 27, 2016 Share Posted December 27, 2016 Merhaba Evet, açık kalacak Link to comment Share on other sites More sharing options...
isam Posted February 19, 2018 Share Posted February 19, 2018 Hello i have test this ...but i have error message Sgcwebsocket is not defined ??? help please Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now