FWebSocketConnection.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. googleAppID:(NSString *)googleAppID
  25. lastSessionID:(NSString *)lastSessionID;
  26. - (void)open;
  27. - (void)close;
  28. - (void)start;
  29. - (void)send:(NSDictionary *)dictionary;
  30. - (void)webSocket:(FSRWebSocket *)webSocket didReceiveMessage:(id)message;
  31. - (void)webSocketDidOpen:(FSRWebSocket *)webSocket;
  32. - (void)webSocket:(FSRWebSocket *)webSocket didFailWithError:(NSError *)error;
  33. - (void)webSocket:(FSRWebSocket *)webSocket
  34. didCloseWithCode:(NSInteger)code
  35. reason:(NSString *)reason
  36. wasClean:(BOOL)wasClean;
  37. @end
  38. @protocol FWebSocketDelegate <NSObject>
  39. - (void)onMessage:(FWebSocketConnection *)fwebSocket
  40. withMessage:(NSDictionary *)message;
  41. - (void)onDisconnect:(FWebSocketConnection *)fwebSocket
  42. wasEverConnected:(BOOL)everConnected;
  43. @end