Skip to content

Commit 9b99784

Browse files
committed
Add get/set user_agent for client
1 parent 853742c commit 9b99784

File tree

4 files changed

+35
-3
lines changed

4 files changed

+35
-3
lines changed

src/internal/sio_client_impl.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,18 @@ namespace sio
165165
}
166166
}
167167

168+
template<typename client_type>
169+
void client_impl<client_type>::set_user_agent(std::string const& ua)
170+
{
171+
m_client.set_user_agent(ua);
172+
}
173+
174+
template<typename client_type>
175+
std::string client_impl<client_type>::get_user_agent()
176+
{
177+
return m_client.get_user_agent();
178+
}
179+
168180
/*************************protected:*************************/
169181
template<typename client_type>
170182
void client_impl<client_type>::send(packet& p)

src/internal/sio_client_impl.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ namespace sio
8080
virtual void set_reconnect_delay(unsigned millis)=0;
8181
virtual void set_reconnect_delay_max(unsigned millis)=0;
8282

83+
virtual void set_user_agent(std::string const& ua)=0;
84+
virtual std::string get_user_agent()=0;
85+
8386
// used by sio::socket
8487
virtual void send(packet& p)=0;
8588
virtual void remove_socket(std::string const& nsp)=0;
@@ -178,6 +181,10 @@ namespace sio
178181
void on_socket_closed(std::string const& nsp);
179182

180183
void on_socket_opened(std::string const& nsp);
184+
185+
void set_user_agent(std::string const& ua);
186+
187+
std::string get_user_agent();
181188

182189
private:
183190
void run_loop();

src/sio_client.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,5 +142,14 @@ namespace sio
142142
{
143143
m_impl->set_reconnect_delay_max(millis);
144144
}
145-
145+
146+
std::string client::get_user_agent() const
147+
{
148+
return m_impl->get_user_agent();
149+
}
150+
151+
void client::set_user_agent(std::string const& ua)
152+
{
153+
m_impl->set_user_agent(ua);
154+
}
146155
}

src/sio_client.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ namespace sio
8080
void set_reconnect_delay(unsigned millis);
8181

8282
void set_reconnect_delay_max(unsigned millis);
83+
84+
std::string get_user_agent() const;
85+
86+
void set_user_agent(std::string const& ua);
8387

8488
sio::socket::ptr const& socket(const std::string& nsp = "");
8589

@@ -94,8 +98,8 @@ namespace sio
9498

9599
private:
96100
//disable copy constructor and assign operator.
97-
client(client const&){}
98-
void operator=(client const&){}
101+
client(client const&) = delete;
102+
void operator=(client const&) = delete;
99103

100104
std::unique_ptr<client_impl_base> m_impl;
101105
};

0 commit comments

Comments
 (0)