11import { EventFormatter } from 'laravel-echo/src/util' ;
2- import { Channel } from 'laravel-echo/src/channel/channel' ;
2+ import { Channel as BaseChannel } from 'laravel-echo/src/channel/channel' ;
33import { PresenceChannel } from "laravel-echo/src/channel" ;
4- import { LaravelEchoApiGatewayWebsocket } from "./LaravelEchoApiGatewayWebsocket " ;
4+ import { Websocket } from "./Websocket " ;
55
66/**
77 * This class represents a Pusher channel.
88 */
9- export class ApiGatewayChannel extends Channel implements PresenceChannel {
9+ export class Channel extends BaseChannel implements PresenceChannel {
1010 /**
1111 * The Pusher client instance.
1212 */
13- socket : LaravelEchoApiGatewayWebsocket ;
13+ socket : Websocket ;
1414
1515 /**
1616 * The name of the channel.
1717 */
18- name : any ;
18+ name : string ;
1919
2020 /**
2121 * Channel options.
2222 */
23- options : any ;
23+ options : object ;
2424
2525 /**
2626 * The event formatter.
@@ -32,13 +32,13 @@ export class ApiGatewayChannel extends Channel implements PresenceChannel {
3232 /**
3333 * Create a new class instance.
3434 */
35- constructor ( socket : LaravelEchoApiGatewayWebsocket , name : any , options : any ) {
35+ constructor ( socket : Websocket , name : string , options : object ) {
3636 super ( ) ;
3737
3838 this . name = name ;
3939 this . socket = socket ;
4040 this . options = options ;
41- this . eventFormatter = new EventFormatter ( this . options . namespace ) ;
41+ this . eventFormatter = new EventFormatter ( this . options [ " namespace" ] ) ;
4242
4343 this . subscribe ( ) ;
4444 }
@@ -54,13 +54,13 @@ export class ApiGatewayChannel extends Channel implements PresenceChannel {
5454 * Unsubscribe from a Pusher channel.
5555 */
5656 unsubscribe ( ) : void {
57- this . socket . unsubscribe ( this . name ) ;
57+ this . socket . unsubscribe ( this ) ;
5858 }
5959
6060 /**
6161 * Listen for an event on the channel instance.
6262 */
63- listen ( event : string , callback : Function ) : ApiGatewayChannel {
63+ listen ( event : string , callback : Function ) : Channel {
6464 this . on ( this . eventFormatter . format ( event ) , callback ) ;
6565
6666 return this ;
@@ -69,7 +69,7 @@ export class ApiGatewayChannel extends Channel implements PresenceChannel {
6969 /**
7070 * Stop listening for an event on the channel instance.
7171 */
72- stopListening ( event : string , callback ?: Function ) : ApiGatewayChannel {
72+ stopListening ( event : string , callback ?: Function ) : Channel {
7373 if ( this . listeners [ event ] && ( ! callback || this . listeners [ event ] === callback ) ) {
7474 delete this . listeners [ event ]
7575 }
@@ -80,7 +80,7 @@ export class ApiGatewayChannel extends Channel implements PresenceChannel {
8080 /**
8181 * Register a callback to be called anytime a subscription succeeds.
8282 */
83- subscribed ( callback : Function ) : ApiGatewayChannel {
83+ subscribed ( callback : Function ) : Channel {
8484 this . on ( 'subscription_succeeded' , ( ) => {
8585 callback ( ) ;
8686 } ) ;
@@ -91,7 +91,7 @@ export class ApiGatewayChannel extends Channel implements PresenceChannel {
9191 /**
9292 * Register a callback to be called anytime a subscription error occurs.
9393 */
94- error ( callback : Function ) : ApiGatewayChannel {
94+ error ( callback : Function ) : Channel {
9595 this . on ( 'error' , ( status ) => {
9696 callback ( status ) ;
9797 } ) ;
@@ -102,19 +102,19 @@ export class ApiGatewayChannel extends Channel implements PresenceChannel {
102102 /**
103103 * Bind a channel to an event.
104104 */
105- on ( event : string , callback : Function ) : ApiGatewayChannel {
105+ on ( event : string , callback : Function ) : Channel {
106106 this . listeners [ event ] = callback
107107
108108 return this ;
109109 }
110110
111- handleEvent ( event : string , data : object ) {
111+ handleEvent ( event : string , data : object ) : void {
112112 if ( this . listeners [ event ] ) {
113113 this . listeners [ event ] ( event , data )
114114 }
115115 }
116116
117- whisper ( event : string , data : object ) : ApiGatewayChannel {
117+ whisper ( event : string , data : object ) : Channel {
118118 this . socket . send ( {
119119 event,
120120 data,
@@ -123,21 +123,27 @@ export class ApiGatewayChannel extends Channel implements PresenceChannel {
123123 return this ;
124124 }
125125
126- here ( callback : Function ) : ApiGatewayChannel {
126+ here ( callback : Function ) : Channel {
127+ // TODO: implement
128+
127129 return this
128130 }
129131
130132 /**
131133 * Listen for someone joining the channel.
132134 */
133- joining ( callback : Function ) : ApiGatewayChannel {
135+ joining ( callback : Function ) : Channel {
136+ // TODO: implement
137+
134138 return this
135139 }
136140
137141 /**
138142 * Listen for someone leaving the channel.
139143 */
140- leaving ( callback : Function ) : ApiGatewayChannel {
144+ leaving ( callback : Function ) : Channel {
145+ // TODO: implement
146+
141147 return this
142148 }
143149}
0 commit comments