how to implement socket.io-stream in angular

28 views Asked by At

how can i implement socket.io-stream in angular. we can use socket.io-stream in web client using browsify https://github.com/nkzawa/socket.io-stream?tab=readme-ov-file#browser. but not work in angular.

i tried to import socket.Io-stream.js import * as SS from './socket.io-stream'; after browsify package but it not work. and gives much error so how can i use it?

1

There are 1 answers

0
Bhautik On BEST ANSWER

after some research i found my question's answer by following

step 1: add cdn into the index.html file

<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io-stream/0.9.1/socket.io-stream.min.js" integrity="sha512-LTN7WQKvmCiOWbwxE4XRu3NCRqLzkFo28vBDHVhAyKjhmorNGjtvFxQgbvAttO31Ij6An4AIXU4GVaYOC0eNpQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>

step 2: declare ss in ts file where you want ss object

declare ss: any;

note: declare ss just after all imports.

and after that you can use like

const stream = ss.createStream()