-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#10 add outline of webscoket visualizer
- Loading branch information
1 parent
5c251a9
commit db46997
Showing
7 changed files
with
73 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,38 @@ | ||
package visualize | ||
|
||
import ( | ||
"context" | ||
"net/http" | ||
|
||
"nhooyr.io/websocket" | ||
) | ||
|
||
type Server struct { | ||
port string | ||
port string | ||
visualizer *Visualizer | ||
clients map[] | ||
} | ||
|
||
func NewServer(port string) *Server { | ||
return &Server{ | ||
port: port, | ||
port: port, | ||
visualizer: NewVisualizer(), | ||
} | ||
} | ||
|
||
func (s *Server) GetVisualizer() *Visualizer { | ||
return s.visualizer | ||
} | ||
|
||
func (s *Server) Start(ctx context.Context) { | ||
handlerFunc := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||
c, err := websocket.Accept(w,r, nil) | ||
if err != nil { | ||
|
||
} | ||
}) | ||
|
||
if err := http.ListenAndServe(s.port, handlerFunc); err != nil { | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package visualize | ||
|
||
import "waffle/internal/request" | ||
|
||
type Visualizer struct { | ||
requestWrappersChan chan request.Wrapper | ||
} | ||
|
||
func NewVisualizer() *Visualizer { | ||
return &Visualizer{ | ||
requestWrappersChan: make(chan request.Wrapper), | ||
} | ||
} | ||
|
||
func (v *Visualizer) VisualizeRequestWrapper(rw request.Wrapper) { | ||
v.requestWrappersChan <- rw | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters