FWebSocketConnection.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * Copyright 2017 Google
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #import "FSRWebSocket.h"
  17. #import "FUtilities.h"
  18. #import <Foundation/Foundation.h>
  19. @protocol FWebSocketDelegate;
  20. @interface FWebSocketConnection : NSObject <FSRWebSocketDelegate>
  21. @property(nonatomic, weak) id<FWebSocketDelegate> delegate;
  22. - (id)initWith:(FRepoInfo *)repoInfo
  23. andQueue:(dispatch_queue_t)queue
  24. lastSessionID:(NSString *)lastSessionID;
  25. - (void)open;
  26. - (void)close;
  27. - (void)start;
  28. - (void)send:(NSDictionary *)dictionary;
  29. - (void)webSocket:(FSRWebSocket *)webSocket didReceiveMessage:(id)message;
  30. - (void)webSocketDidOpen:(FSRWebSocket *)webSocket;
  31. - (void)webSocket:(FSRWebSocket *)webSocket didFailWithError:(NSError *)error;
  32. - (void)webSocket:(FSRWebSocket *)webSocket
  33. didCloseWithCode:(NSInteger)code
  34. reason:(NSString *)reason
  35. wasClean:(BOOL)wasClean;
  36. @end
  37. @protocol FWebSocketDelegate <NSObject>
  38. - (void)onMessage:(FWebSocketConnection *)fwebSocket
  39. withMessage:(NSDictionary *)message;
  40. - (void)onDisconnect:(FWebSocketConnection *)fwebSocket
  41. wasEverConnected:(BOOL)everConnected;
  42. @end