hangyeol_channel

Last updated:

0 purchases

hangyeol_channel Image
hangyeol_channel Images
Add to Cart

Description:

hangyeol channel

Easy channel connect implementation util
Features #
onData() 만 override하면 끝!
Getting started #

HangyeolChannelInterface 클래스를 상속받은 클래스 작성
onData 메서드 event객체에 통신 내용이 들어온다. 로직을 작성하자
클래스 인스턴스를 만들고 .connet() 하면 연결 완료

Usage #

클래스 정의

class SampleChannel extends HangyeolChannelInterface {
SampleChannel({
required String url,
required Map<String, Object> payload,
}) : super(url, payload);

@override
Future<void> onData(ChannelEvent event, IOWebSocketChannel channel) async {
switch (event.type) {
case 'request':
channel.sink.add(encode('response', {'key': 'value'}));
break;
}
}
}

copied to clipboard

사용

final channel = SampleChannel(
url: 'your host', payload: {'required': 'values', 'on every': 'send'});

channel.connect();
channel.add('send', {'key': 'value'});
channel.exit();
copied to clipboard

logging

class LogingChannel extends HangyeolChannelInterface {
...

@override
void log(Map<String, dynamic> event){
// your logging stratage;
// defualt : print(event);
}
}


final channel = LogingChannel(
url: 'your host',
payload: {'required': 'values', 'on every': 'send'},
logging: true,
);

copied to clipboard

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.