All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.envision.energy.connective.protobuf.AuthResMessageProcessor Maven / Gradle / Ivy

There is a newer version: 3.0.3
Show newest version
package com.envision.energy.connective.protobuf;

import io.netty.channel.ChannelHandler.Sharable;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;

import com.envision.energy.connective.protobuf.generated.Sdk.SDKAuthRes;
import com.envision.energy.eos.sdk.ProxyManager;

@Sharable
public class AuthResMessageProcessor extends ChannelInboundHandlerAdapter {

	public AuthResMessageProcessor() {
	}
	
	@Override
	public void channelRead(ChannelHandlerContext ctx, Object msg)
			throws Exception {
		//to next handler
		if(msg == null || msg.getClass() != SDKAuthRes.class) {
			ctx.fireChannelRead(msg);
			return;
		}
		
		SDKAuthRes data = (SDKAuthRes)msg;
		
		
		if(data.getSvrTime() < 0) {
			ProxyManager.INSTANCE.closeTransport();
		} else {
			if(data.hasToken()) {
				ProxyManager.INSTANCE.setToken(data.getToken());
			}
			ProxyManager.INSTANCE.subscribe(); //subuscribe.
		}
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy