Skip to content

Commit

Permalink
Merge pull request #11 from fugle-dev/fix/onClose
Browse files Browse the repository at this point in the history
fix: onClose event argument error
  • Loading branch information
bistin authored May 2, 2023
2 parents 21035ad + bd107ad commit 9d8ff14
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## [0.5.1](https://github.com/fugle-dev/fugle-trade-python/compare/0.5.0...0.5.1) -
### Fixed
- 修正 on_close callback 的參數錯誤


## [0.5.0](https://github.com/fugle-dev/fugle-trade-python/compare/0.4.0...0.5.0) -
### Added
Expand Down
11 changes: 6 additions & 5 deletions fugle_trade/websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
from websocket import WebSocketApp
from fugle_trade_core.fugle_trade_core import convert_ws_object


class WebsocketHandler():
"""Handle Websocket connection"""
def __init__(self):
self.__ws = None
default_fun = lambda x: print("in default function")
default_fun = lambda x, *y: print("in default function")
self.on_order = default_fun
self.on_dealt = default_fun
self.on_error = default_fun
Expand All @@ -33,9 +34,9 @@ def ws_on_error(self, _, error):
"""callback function for websocket error"""
self.on_error(error)

def ws_on_close(self, _, error):
def ws_on_close(self, ws, close_status_code, close_msg):
"""callback function for websocket close"""
self.on_close(error)
self.on_close(ws, close_status_code, close_msg)

def set_callback(self, name, func):
"""for upper scope to set different types of callback function"""
Expand All @@ -45,10 +46,10 @@ def set_callback(self, name, func):
else:
raise Exception("callback " + name + " not allowed")

def connect_websocket(self, urlEntry):
def connect_websocket(self, url_entry):
"""start to connect websocket"""
self.__ws = WebSocketApp(
urlEntry,
url_entry,
on_message=self.ws_on_message,
on_error=self.ws_on_error,
on_close=self.ws_on_close
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "fugle-trade"
version = "0.5.0"
version = "0.5.1"
description = ""
authors = ["Fortuna Intelligence Co., Ltd. <development@fugle.tw>"]
license = "MIT"
Expand Down

0 comments on commit 9d8ff14

Please sign in to comment.