jacklongway / androidsocketcore Goto Github PK
View Code? Open in Web Editor NEWa lite socket base library
License: MIT License
a lite socket base library
License: MIT License
NetworkMonitorReceiver类
private static final LinkedList mObservable = new LinkedList();
改为:
private static final LinkedList mObservable = new LinkedList<>();
这样就不会有橙色的警告了.看着也舒服了...哈哈
还有if (networkMonitors != null) {
报警告,此判断语句永远为真,我认真看了看发现也确实是这样.
如果改成这样可以吗????
private void notifyNetworkMonitor(boolean success, int type, String reason) {
synchronized (mObservable) {
for (NetworkMonitor chine : mObservable) {
if (success) {
chine.onConnect(type);
} else {
chine.onDisconnected(reason);
}
}
}
}
3.int type = intent.getIntExtra(ConnectivityManager.EXTRA_NETWORK_TYPE, -1);
这个方法没有指明API使用级别为16以上.我设备是14,所以这里老是会判断为无网络.这是错误的判断.
1):R文件引用包位置错误导致
2):一直报空,要么判空下,要么把start提前在各种监听之前运行.
3):发送数据编码无法改变.
4):ping的数据很不稳定,服务器不是每隔X秒后收到ping的数据,而是不确定时间收到不确定的ping条数据........
5):如果服务器主动端口连接的话会导致SocketChannelClient类中的while (iterator.hasNext())死循环.
发送数据太大数据发送不全对方无法获取全部数据
百度搜索后找到解决办法(但不知为何要sleep),
此方法在SocketChannelClient类里,.
void writeMessageToServer(byte[] msg) throws Exception {
if (isConnected()) {
// mSocketChannelClient.write(ByteBuffer.wrap(msg));
ByteBuffer wrap = ByteBuffer.wrap(msg);
if (wrap != null) {
while (wrap.hasRemaining()) {
int len = mSocketChannelClient.write(wrap);
Thread.sleep(500);
if(len < 0){
throw new Exception();
}
if(len == 0){
break;
}
}
}
}
}
测试环境,图片转Base64后(700多KB)发送给服务器.就会出现这个问题.系统版本安卓4.0.1
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.