This file contains hidden or 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
| port := 50051 // we'll implement command line arguments leter | |
| lis, err := net.Listen("tcp", fmt.Sprintf("localhost:%d", *port)) | |
| if err != nil { | |
| log.Fatalf("failed to listen: %v", err) | |
| } |
This file contains hidden or 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
| var opts []grpc.ServerOption | |
| grpcServer := grpc.NewServer(opts...) |
This file contains hidden or 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
| pb.RegisterTheSocialRobotServer(grpcServer, new(theSocialRobotServer)) |
This file contains hidden or 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
| grpcServer.Serve(lis) |
This file contains hidden or 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
| type TheSocialRobotClient interface { | |
| EventStream(ctx context.Context, opts ...grpc.CallOption) (TheSocialRobot_EventStreamClient, error) | |
| } |
This file contains hidden or 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
| var opts []grpc.DialOption | |
| serverAddr := "localhost:50051" | |
| conn, err := grpc.Dial(*serverAddr, opts...) | |
| if err != nil { | |
| log.Fatalf("fail to dial: %v", err) | |
| } | |
| defer conn.Close() | |
| client := pb.NewTheSocialRobotClient(conn) |
This file contains hidden or 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
| import 'package:flutter/material.dart'; | |
| import 'package:path/path.dart'; | |
| import 'package:sqflite/sqflite.dart'; | |
| void main() => runApp(MyApp()); | |
| class MyApp extends StatelessWidget { | |
| @override | |
| Widget build(BuildContext context) { | |
| return MaterialApp( |
This file contains hidden or 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
| package main | |
| import ( | |
| "context" | |
| "fmt" | |
| "io" | |
| "time" | |
| "google.golang.org/grpc" | |
| "google.golang.org/grpc/codes" |
This file contains hidden or 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
| #include <alsa/asoundlib.h> | |
| #include <flac++/encoder.h> | |
| #include <cstdio> | |
| #include <cstring> | |
| constexpr int kSampleRate = 44100; // Sample rate in Hz | |
| constexpr int kNumChannels = 2; // Number of channels | |
| constexpr int kBufferSize = 4096; // Size of the audio buffer |
This file contains hidden or 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
| #include <alsa/asoundlib.h> | |
| #include <iostream> | |
| int main() { | |
| // Open the default PCM device | |
| snd_pcm_t *handle; | |
| int error = snd_pcm_open(&handle, "default", SND_PCM_STREAM_CAPTURE, 0); | |
| if (error < 0) { | |
| std::cerr << "Error opening PCM device: " << snd_strerror(error) << std::endl; | |
| return 1; |